-#define ENABLE_TIMEOUT(socket) \
-{ \
- struct itimerval old_ival, new_ival; \
- void (*old_timer_sig)(int); \
-\
- old_timer_sig = signal(SIGALRM, SIG_DFL); \
- siginterrupt(SIGALRM, 1); \
- new_ival.it_value.tv_sec = socket->m_timeout / 1000; \
- new_ival.it_value.tv_usec = (socket->m_timeout % 1000) * 1000; \
- new_ival.it_interval.tv_sec = 0; \
- new_ival.it_interval.tv_usec = 0; \
- setitimer(ITIMER_REAL, &new_ival, &old_ival);
-
-#define DISABLE_TIMEOUT(socket) \
- signal(SIGALRM, old_timer_sig); \
- siginterrupt(SIGALRM, 0); \
- setitimer(ITIMER_REAL, &old_ival, NULL); \
-}
+
+#ifndef __GSOCKET_STANDALONE__
+# include "wx/unix/gsockunx.h"
+# include "wx/gsocket.h"
+#else
+# include "gsockunx.h"
+# include "gsocket.h"
+#endif /* __GSOCKET_STANDALONE__ */
+
+/* debugging helpers */
+#ifdef __GSOCKET_DEBUG__
+# define GSocket_Debug(args) printf args
+#else
+# define GSocket_Debug(args)
+#endif /* __GSOCKET_DEBUG__ */
+
+/* Table of GUI-related functions. We must call them indirectly because
+ * of wxBase and GUI separation: */
+
+static struct GSocketGUIFunctionsTable *gs_gui_functions;
+
+#define USE_GUI() (gs_gui_functions != NULL)
+
+/* Define macros to simplify indirection: */
+#define _GSocket_GUI_Init() \
+ if (gs_gui_functions) gs_gui_functions->GUI_Init()
+#define _GSocket_GUI_Cleanup() \
+ if (gs_gui_functions) gs_gui_functions->GUI_Cleanup()
+#define _GSocket_GUI_Init_Socket(socket) \
+ (gs_gui_functions ? gs_gui_functions->GUI_Init_Socket(socket) : 1)
+#define _GSocket_GUI_Destroy_Socket(socket) \
+ if (gs_gui_functions) gs_gui_functions->GUI_Destroy_Socket(socket)
+#define _GSocket_Enable_Events(socket) \
+ if (gs_gui_functions) gs_gui_functions->Enable_Events(socket)
+#define _GSocket_Disable_Events(socket) \
+ if (gs_gui_functions) gs_gui_functions->Disable_Events(socket)
+#define _GSocket_Install_Callback(socket, event) \
+ if (gs_gui_functions) gs_gui_functions->Install_Callback(socket, event)
+#define _GSocket_Uninstall_Callback(socket, event) \
+ if (gs_gui_functions) gs_gui_functions->Uninstall_Callback(socket, event)
+
+static struct GSocketBaseFunctionsTable gs_base_functions =
+{
+ _GSocket_Detected_Read,
+ _GSocket_Detected_Write
+};