Commit 9475035103cd17a79c6ef7a7374b7b01bad26483

Authored by Perry Werneck
1 parent 08f6b59a
Exists in master and in 1 other branch develop

Updating I/O Sources. Starting split of windows/linux sources.

Makefile.in
... ... @@ -31,6 +31,7 @@ LIBNAME=libv@LIB3270_NAME@
31 31 SOURCES= \
32 32 $(wildcard src/v3270/*.c) \
33 33 $(wildcard src/v3270/@OSNAME@/*.rc) \
  34 + $(wildcard src/v3270/@OSNAME@/*.c) \
34 35 $(wildcard src/v3270ft/*.c) \
35 36 $(wildcard src/dialogs/*.c)
36 37  
... ...
gitsync.sh
... ... @@ -12,6 +12,8 @@
12 12 #
13 13 #
14 14  
  15 +git push
  16 +
15 17 git fetch origin
16 18 git checkout master
17 19 git merge origin/master
... ...
src/v3270/iocallback.c
... ... @@ -1,322 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como iocallback.c e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include <config.h>
33   -
34   - #define ENABLE_NLS
35   - #define GETTEXT_PACKAGE PACKAGE_NAME
36   -
37   - #include <gtk/gtk.h>
38   - #include <libintl.h>
39   - #include <glib/gi18n.h>
40   -
41   -#if defined(_WIN32) /*[*/
42   - #include <windows.h>
43   -#elif defined(__APPLE__)
44   - #include <poll.h>
45   - #include <string.h>
46   -#else
47   - #include <poll.h>
48   - #include <string.h>
49   -#endif /*]*/
50   -
51   -#include <lib3270.h>
52   -#include <v3270.h>
53   -#include <stdio.h>
54   -#include <glib.h>
55   -
56   -static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata);
57   -static void static_RemoveSource(H3270 *session, void *id);
58   -
59   -static void * static_AddTimeOut(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session));
60   -static void static_RemoveTimeOut(H3270 *session, void * timer);
61   -static int static_Sleep(H3270 *hSession, int seconds);
62   -static int static_RunPendingEvents(H3270 *hSession, int wait);
63   -
64   -static gboolean IO_prepare(GSource *source, gint *timeout);
65   -static gboolean IO_check(GSource *source);
66   -static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
67   -static void IO_finalize(GSource *source); /* Can be NULL */
68   -static gboolean IO_closure(gpointer data);
69   -
70   -/*---[ Structs ]-------------------------------------------------------------------------------------------*/
71   -
72   - typedef struct _IO_Source
73   - {
74   - GSource gsrc;
75   - GPollFD poll;
76   - int fd;
77   - void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *);
78   - H3270 *session;
79   - void *userdata;
80   - } IO_Source;
81   -
82   - typedef struct _timer
83   - {
84   - unsigned char remove;
85   - void * userdata;
86   - void (*call)(H3270 *session);
87   - H3270 * session;
88   - } TIMER;
89   -
90   - static GSourceFuncs IOSources =
91   - {
92   - IO_prepare,
93   - IO_check,
94   - IO_dispatch,
95   - IO_finalize,
96   - IO_closure,
97   - NULL
98   - };
99   -
100   -/*---[ Implement ]-----------------------------------------------------------------------------------------*/
101   -
102   -static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata)
103   -{
104   - IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source));
105   -
106   - src->fd = fd;
107   - src->call = call;
108   - src->userdata = userdata;
109   - src->session = session;
110   -
111   - src->poll.fd = (int) fd;
112   - src->poll.events = G_IO_HUP|G_IO_ERR;
113   -
114   - if(flag & LIB3270_IO_FLAG_READ)
115   - src->poll.events |= G_IO_IN;
116   -
117   - if(flag & LIB3270_IO_FLAG_WRITE)
118   - src->poll.events |= G_IO_OUT;
119   -
120   - g_source_attach((GSource *) src,NULL);
121   - g_source_add_poll((GSource *) src,&src->poll);
122   -
123   - return src;
124   -}
125   -
126   -static void static_RemoveSource(G_GNUC_UNUSED H3270 *session, void *id)
127   -{
128   - if(id)
129   - g_source_destroy((GSource *) id);
130   -}
131   -
132   -static gboolean do_timer(TIMER *t)
133   -{
134   - if(!t->remove)
135   - t->call(t->session);
136   - return FALSE;
137   -}
138   -
139   -static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*call)(H3270 *session))
140   -{
141   - TIMER *t = g_malloc0(sizeof(TIMER));
142   -
143   - t->call = call;
144   - t->session = session;
145   -
146   - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) interval, (GSourceFunc) do_timer, t, g_free);
147   -
148   - return t;
149   -}
150   -
151   -static void static_RemoveTimeOut(G_GNUC_UNUSED H3270 *session, void * timer)
152   -{
153   - ((TIMER *) timer)->remove++;
154   -}
155   -
156   -static gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout)
157   -{
158   - /*
159   - * Called before all the file descriptors are polled.
160   - * If the source can determine that it is ready here
161   - * (without waiting for the results of the poll() call)
162   - * it should return TRUE.
163   - *
164   - * It can also return a timeout_ value which should be the maximum
165   - * timeout (in milliseconds) which should be passed to the poll() call.
166   - * The actual timeout used will be -1 if all sources returned -1,
167   - * or it will be the minimum of all the timeout_ values
168   - * returned which were >= 0.
169   - *
170   - */
171   - return 0;
172   -}
173   -
174   -static gboolean IO_check(GSource *source)
175   -{
176   - /*
177   - * Called after all the file descriptors are polled.
178   - * The source should return TRUE if it is ready to be dispatched.
179   - * Note that some time may have passed since the previous prepare
180   - * function was called, so the source should be checked again here.
181   - *
182   - */
183   -#ifdef _WIN32
184   -
185   - fd_set rfds, wfds;
186   - struct timeval tm;
187   -
188   - memset(&tm,0,sizeof(tm));
189   -
190   - FD_ZERO(&rfds);
191   - FD_ZERO(&wfds);
192   -// FD_ZERO(&xfds);
193   -
194   - if(((IO_Source *) source)->poll.events & G_IO_IN)
195   - {
196   - FD_SET(((IO_Source *) source)->poll.fd, &rfds);
197   - }
198   -
199   - if(((IO_Source *) source)->poll.events & G_IO_OUT)
200   - {
201   - FD_SET(((IO_Source *) source)->poll.fd, &wfds);
202   - }
203   -
204   - if(select(((IO_Source *) source)->poll.fd+1, &rfds, &wfds, NULL, &tm) > 0)
205   - return TRUE;
206   -
207   -#else
208   -
209   - struct pollfd fds;
210   -
211   - memset(&fds,0,sizeof(fds));
212   -
213   - fds.fd = ((IO_Source *) source)->poll.fd;
214   - fds.events = ((IO_Source *) source)->poll.events;
215   -
216   - if(poll(&fds,1,0) > 0)
217   - return TRUE;
218   -
219   -#endif // _WIN32
220   -
221   - return FALSE;
222   -}
223   -
224   -static gboolean IO_dispatch(GSource *source, G_GNUC_UNUSED GSourceFunc callback, G_GNUC_UNUSED gpointer user_data)
225   -{
226   - /*
227   - * Called to dispatch the event source,
228   - * after it has returned TRUE in either its prepare or its check function.
229   - * The dispatch function is passed in a callback function and data.
230   - * The callback function may be NULL if the source was never connected
231   - * to a callback using g_source_set_callback(). The dispatch function
232   - * should call the callback function with user_data and whatever additional
233   - * parameters are needed for this type of event source.
234   - */
235   - IO_Source *obj = (IO_Source *) source;
236   -
237   - obj->call(obj->session,obj->fd,0,obj->userdata);
238   -
239   - return TRUE;
240   -}
241   -
242   -static void IO_finalize(G_GNUC_UNUSED GSource *source)
243   -{
244   -
245   -}
246   -
247   -static gboolean IO_closure(G_GNUC_UNUSED gpointer data)
248   -{
249   - return 0;
250   -}
251   -
252   -struct bgParameter
253   -{
254   - gboolean running;
255   - H3270 *session;
256   - int rc;
257   - int(*callback)(H3270 *session, void *);
258   - void *parm;
259   -
260   -};
261   -
262   -gpointer BgCall(struct bgParameter *p)
263   -{
264   - p->rc = p->callback(p->session, p->parm);
265   - p->running = FALSE;
266   - return 0;
267   -}
268   -
269   -static int static_Sleep(G_GNUC_UNUSED H3270 *hSession, int seconds)
270   -{
271   - time_t end = time(0) + seconds;
272   -
273   - while(time(0) < end)
274   - gtk_main_iteration();
275   -
276   - return 0;
277   -}
278   -
279   -static int static_RunPendingEvents(G_GNUC_UNUSED H3270 *hSession, int wait)
280   -{
281   - int rc = 0;
282   - while(gtk_events_pending())
283   - {
284   - rc = 1;
285   - gtk_main_iteration();
286   - }
287   -
288   - if(wait)
289   - gtk_main_iteration();
290   -
291   - return rc;
292   -}
293   -
294   -static void beep(G_GNUC_UNUSED H3270 *session)
295   -{
296   - gdk_display_beep(gdk_display_get_default());
297   -}
298   -
299   -void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls)
300   -{
301   - static const struct lib3270_callbacks hdl =
302   - {
303   - sizeof(struct lib3270_callbacks),
304   -
305   - static_AddTimeOut,
306   - static_RemoveTimeOut,
307   -
308   - static_AddSource,
309   - static_RemoveSource,
310   -
311   - static_Sleep,
312   - static_RunPendingEvents,
313   - beep
314   -
315   - };
316   -
317   - if(lib3270_register_handlers(&hdl))
318   - {
319   - g_error("%s",_( "Can't set lib3270 I/O handlers" ) );
320   - }
321   -
322   -}
src/v3270/linux/iosource.c 0 → 100644
... ... @@ -0,0 +1,114 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <config.h>
  31 + #include "../private.h"
  32 +
  33 +/*---[ Structs ]-------------------------------------------------------------------------------------------*/
  34 +
  35 + typedef struct _IO_Source
  36 + {
  37 + GSource gsrc;
  38 + GPollFD poll;
  39 + gboolean enabled;
  40 + int fd;
  41 + void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *);
  42 + H3270 * session;
  43 + void * userdata;
  44 + } IO_Source;
  45 +
  46 +/*---[ Implement ]-----------------------------------------------------------------------------------------*/
  47 +
  48 +gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout)
  49 +{
  50 + /*
  51 + * Called before all the file descriptors are polled.
  52 + * If the source can determine that it is ready here
  53 + * (without waiting for the results of the poll() call)
  54 + * it should return TRUE.
  55 + *
  56 + * It can also return a timeout_ value which should be the maximum
  57 + * timeout (in milliseconds) which should be passed to the poll() call.
  58 + * The actual timeout used will be -1 if all sources returned -1,
  59 + * or it will be the minimum of all the timeout_ values
  60 + * returned which were >= 0.
  61 + *
  62 + */
  63 + return 0;
  64 +}
  65 +
  66 +gboolean IO_check(GSource *source)
  67 +{
  68 + /*
  69 + * Called after all the file descriptors are polled.
  70 + * The source should return TRUE if it is ready to be dispatched.
  71 + * Note that some time may have passed since the previous prepare
  72 + * function was called, so the source should be checked again here.
  73 + *
  74 + */
  75 + struct pollfd fds;
  76 +
  77 + memset(&fds,0,sizeof(fds));
  78 +
  79 + fds.fd = ((IO_Source *) source)->poll.fd;
  80 + fds.events = ((IO_Source *) source)->poll.events;
  81 +
  82 + if(poll(&fds,1,0) > 0)
  83 + return TRUE;
  84 +
  85 + return FALSE;
  86 +}
  87 +
  88 +gboolean IO_dispatch(GSource *source, G_GNUC_UNUSED GSourceFunc callback, G_GNUC_UNUSED gpointer user_data)
  89 +{
  90 + /*
  91 + * Called to dispatch the event source,
  92 + * after it has returned TRUE in either its prepare or its check function.
  93 + * The dispatch function is passed in a callback function and data.
  94 + * The callback function may be NULL if the source was never connected
  95 + * to a callback using g_source_set_callback(). The dispatch function
  96 + * should call the callback function with user_data and whatever additional
  97 + * parameters are needed for this type of event source.
  98 + */
  99 + IO_Source *obj = (IO_Source *) source;
  100 +
  101 + obj->call(obj->session,obj->fd,0,obj->userdata);
  102 +
  103 + return TRUE;
  104 +}
  105 +
  106 +void IO_finalize(G_GNUC_UNUSED GSource *source)
  107 +{
  108 +
  109 +}
  110 +
  111 +gboolean IO_closure(G_GNUC_UNUSED gpointer data)
  112 +{
  113 + return 0;
  114 +}
... ...
src/v3270/private.h
... ... @@ -315,25 +315,31 @@ G_GNUC_INTERNAL void v3270_update_cursor(H3270 *session, unsigned short row,
315 315 G_GNUC_INTERNAL void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on);
316 316 G_GNUC_INTERNAL void v3270_update_ssl(H3270 *session, LIB3270_SSL_STATE state);
317 317  
318   -G_GNUC_INTERNAL void v3270_update_luname(GtkWidget *widget,const gchar *name);
319   -G_GNUC_INTERNAL void v3270_init_properties(GObjectClass * gobject_class);
320   -G_GNUC_INTERNAL void v3270_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint height);
  318 +G_GNUC_INTERNAL void v3270_update_luname(GtkWidget *widget,const gchar *name);
  319 +G_GNUC_INTERNAL void v3270_init_properties(GObjectClass * gobject_class);
  320 +G_GNUC_INTERNAL void v3270_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint height);
321 321  
322   -G_GNUC_INTERNAL void v3270_disable_updates(GtkWidget *widget);
323   -G_GNUC_INTERNAL void v3270_enable_updates(GtkWidget *widget);
  322 +G_GNUC_INTERNAL void v3270_disable_updates(GtkWidget *widget);
  323 +G_GNUC_INTERNAL void v3270_enable_updates(GtkWidget *widget);
324 324  
325 325 // Keyboard & Mouse
326   -G_GNUC_INTERNAL gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event);
327   -G_GNUC_INTERNAL gboolean v3270_key_release_event(GtkWidget *widget, GdkEventKey *event);
328   -G_GNUC_INTERNAL void v3270_key_commit(GtkIMContext *imcontext, gchar *str, v3270 *widget);
329   -G_GNUC_INTERNAL gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event);
330   -G_GNUC_INTERNAL gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event);
331   -G_GNUC_INTERNAL gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event);
332   -G_GNUC_INTERNAL void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event);
333   -G_GNUC_INTERNAL gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y);
334   -G_GNUC_INTERNAL gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event);
335   -
336   -G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget);
337   -
  326 +G_GNUC_INTERNAL gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event);
  327 +G_GNUC_INTERNAL gboolean v3270_key_release_event(GtkWidget *widget, GdkEventKey *event);
  328 +G_GNUC_INTERNAL void v3270_key_commit(GtkIMContext *imcontext, gchar *str, v3270 *widget);
  329 +G_GNUC_INTERNAL gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event);
  330 +G_GNUC_INTERNAL gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event);
  331 +G_GNUC_INTERNAL gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event);
  332 +G_GNUC_INTERNAL void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event);
  333 +G_GNUC_INTERNAL gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y);
  334 +G_GNUC_INTERNAL gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event);
  335 +
  336 +G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget);
  337 +
  338 +// I/O Callbacks
  339 +G_GNUC_INTERNAL gboolean IO_prepare(GSource *source, gint *timeout);
  340 +G_GNUC_INTERNAL gboolean IO_check(GSource *source);
  341 +G_GNUC_INTERNAL gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
  342 +G_GNUC_INTERNAL void IO_finalize(GSource *source); /* Can be NULL */
  343 +G_GNUC_INTERNAL gboolean IO_closure(gpointer data);
338 344  
339 345 G_END_DECLS
... ...
src/v3270/windows/iosource.c 0 → 100644
... ... @@ -0,0 +1,126 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como - e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include <config.h>
  31 + #include "../private.h"
  32 +
  33 +/*---[ Structs ]-------------------------------------------------------------------------------------------*/
  34 +
  35 + typedef struct _IO_Source
  36 + {
  37 + GSource gsrc;
  38 + GPollFD poll;
  39 + gboolean enabled;
  40 + int fd;
  41 + void (*call)(H3270 *, int, LIB3270_IO_FLAG, void *);
  42 + H3270 * session;
  43 + void * userdata;
  44 + } IO_Source;
  45 +
  46 +/*---[ Implement ]-----------------------------------------------------------------------------------------*/
  47 +
  48 +static gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout)
  49 +{
  50 + /*
  51 + * Called before all the file descriptors are polled.
  52 + * If the source can determine that it is ready here
  53 + * (without waiting for the results of the poll() call)
  54 + * it should return TRUE.
  55 + *
  56 + * It can also return a timeout_ value which should be the maximum
  57 + * timeout (in milliseconds) which should be passed to the poll() call.
  58 + * The actual timeout used will be -1 if all sources returned -1,
  59 + * or it will be the minimum of all the timeout_ values
  60 + * returned which were >= 0.
  61 + *
  62 + */
  63 + return 0;
  64 +}
  65 +
  66 +static gboolean IO_check(GSource *source)
  67 +{
  68 + /*
  69 + * Called after all the file descriptors are polled.
  70 + * The source should return TRUE if it is ready to be dispatched.
  71 + * Note that some time may have passed since the previous prepare
  72 + * function was called, so the source should be checked again here.
  73 + *
  74 + */
  75 + fd_set rfds, wfds;
  76 + struct timeval tm;
  77 +
  78 + memset(&tm,0,sizeof(tm));
  79 +
  80 + FD_ZERO(&rfds);
  81 + FD_ZERO(&wfds);
  82 +// FD_ZERO(&xfds);
  83 +
  84 + if(((IO_Source *) source)->poll.events & G_IO_IN)
  85 + {
  86 + FD_SET(((IO_Source *) source)->poll.fd, &rfds);
  87 + }
  88 +
  89 + if(((IO_Source *) source)->poll.events & G_IO_OUT)
  90 + {
  91 + FD_SET(((IO_Source *) source)->poll.fd, &wfds);
  92 + }
  93 +
  94 + if(select(((IO_Source *) source)->poll.fd+1, &rfds, &wfds, NULL, &tm) > 0)
  95 + return TRUE;
  96 +
  97 + return FALSE;
  98 +}
  99 +
  100 +static gboolean IO_dispatch(GSource *source, G_GNUC_UNUSED GSourceFunc callback, G_GNUC_UNUSED gpointer user_data)
  101 +{
  102 + /*
  103 + * Called to dispatch the event source,
  104 + * after it has returned TRUE in either its prepare or its check function.
  105 + * The dispatch function is passed in a callback function and data.
  106 + * The callback function may be NULL if the source was never connected
  107 + * to a callback using g_source_set_callback(). The dispatch function
  108 + * should call the callback function with user_data and whatever additional
  109 + * parameters are needed for this type of event source.
  110 + */
  111 + IO_Source *obj = (IO_Source *) source;
  112 +
  113 + obj->call(obj->session,obj->fd,0,obj->userdata);
  114 +
  115 + return TRUE;
  116 +}
  117 +
  118 +static void IO_finalize(G_GNUC_UNUSED GSource *source)
  119 +{
  120 +
  121 +}
  122 +
  123 +static gboolean IO_closure(G_GNUC_UNUSED gpointer data)
  124 +{
  125 + return 0;
  126 +}
... ...