]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/gsockmot.c
   1 /* ------------------------------------------------------------------------- 
   2  * Project: GSocket (Generic Socket) for WX 
   4  * Purpose: GSocket: Motif part 
   6  * Licence: The wxWindows licence 
   7  * ------------------------------------------------------------------------- */ 
  14 #include <X11/Intrinsic.h> 
  15 #include "wx/gsocket.h" 
  16 #include "wx/unix/gsockunx.h" 
  18 extern XtAppContext 
wxGetAppContext(); 
  20 static void _GSocket_Motif_Input(XtPointer data
, int *fid
, 
  23   GSocket 
*socket 
= (GSocket 
*)data
; 
  25   socket
->m_functions
->Detected_Read(socket
); 
  28 static void _GSocket_Motif_Output(XtPointer data
, int *fid
, 
  31   GSocket 
*socket 
= (GSocket 
*)data
; 
  33   socket
->m_functions
->Detected_Write(socket
); 
  36 int _GSocket_GUI_Init(void) 
  41 void _GSocket_GUI_Cleanup(void) 
  45 int _GSocket_GUI_Init_Socket(GSocket 
*socket
) 
  49   socket
->m_gui_dependent 
= (char *)malloc(sizeof(int)*2); 
  50   m_id 
= (int *)(socket
->m_gui_dependent
); 
  58 void _GSocket_GUI_Destroy_Socket(GSocket 
*socket
) 
  60   free(socket
->m_gui_dependent
); 
  63 void _GSocket_Install_Callback(GSocket 
*socket
, GSocketEvent event
) 
  65   int *m_id 
= (int *)(socket
->m_gui_dependent
); 
  68   if (socket
->m_fd 
== -1) 
  73     case GSOCK_LOST
:       /* fall-through */ 
  74     case GSOCK_INPUT
:      c 
= 0; break; 
  75     case GSOCK_OUTPUT
:     c 
= 1; break; 
  76     case GSOCK_CONNECTION
: c 
= ((socket
->m_server
) ? 0 : 1); break; 
  81     XtRemoveInput(m_id
[c
]); 
  85      m_id
[0] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
, 
  86                              (XtPointer 
*)XtInputReadMask
, 
  87                              (XtInputCallbackProc
) _GSocket_Motif_Input
, 
  92      m_id
[1] = XtAppAddInput(wxGetAppContext(), socket
->m_fd
, 
  93                              (XtPointer 
*)XtInputWriteMask
, 
  94                              (XtInputCallbackProc
) _GSocket_Motif_Output
, 
  99 void _GSocket_Uninstall_Callback(GSocket 
*socket
, GSocketEvent event
) 
 101   int *m_id 
= (int *)(socket
->m_gui_dependent
); 
 106     case GSOCK_LOST
:       /* fall-through */ 
 107     case GSOCK_INPUT
:      c 
= 0; break; 
 108     case GSOCK_OUTPUT
:     c 
= 1; break; 
 109     case GSOCK_CONNECTION
: c 
= ((socket
->m_server
) ? 0 : 1); break; 
 114     XtRemoveInput(m_id
[c
]); 
 119 void _GSocket_Enable_Events(GSocket 
*socket
) 
 121   _GSocket_Install_Callback(socket
, GSOCK_INPUT
); 
 122   _GSocket_Install_Callback(socket
, GSOCK_OUTPUT
); 
 125 void _GSocket_Disable_Events(GSocket 
*socket
) 
 127   _GSocket_Uninstall_Callback(socket
, GSOCK_INPUT
); 
 128   _GSocket_Uninstall_Callback(socket
, GSOCK_OUTPUT
); 
 131 #else /* !wxUSE_SOCKETS */ 
 133 /* some compilers don't like having empty source files */ 
 134 static int wxDummyGsockVar 
= 0; 
 136 #endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */