]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/gsocket.c
regenerated
[wxWidgets.git] / src / os2 / gsocket.c
index 0ea14036b81d920ba78b201778abd4165fd95857..8ba4efe94a37ca7e31e2dd789f499fccfb1c4cf5 100644 (file)
@@ -7,7 +7,12 @@
  */
 
 #include "wx/setup.h"
+#ifndef __EMX__
+/* I don't see, why this include is needed, but it seems to be necessary
+   sometimes. For EMX, including C++ headers into plain C source breaks
+   compilation, so don't do it there.                                   */
 #include "wx/defs.h"
+#endif
 
 #if wxUSE_SOCKETS
 
 
 #include <assert.h>
 #include <sys\types.h>
+#ifdef __EMX__
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <errno.h>
+#define HAVE_INET_ADDR
+#else
 #include <utils.h>
 #include <sys\time.h>
 #include <in.h>
 #include <netdb.h>
 #include <nerrno.h>
+#endif
 #if defined(__VISAGECPP__) && __IBMCPP__ < 400
 #include <socket.h>
 #include <ioctl.h>
@@ -28,6 +42,9 @@
 #include <sys\socket.h>
 #include <sys\ioctl.h>
 #include <sys\select.h>
+#ifdef __EMX__
+#define soclose(a) close(a)
+#else
 #define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
 int _System bsdselect(int,
                       struct fd_set *,
@@ -36,6 +53,7 @@ int _System bsdselect(int,
                       struct timeval *);
 int _System soclose(int);
 #endif
+#endif
 
 #include <string.h>
 #include <stdio.h>
@@ -62,9 +80,9 @@ int _System soclose(int);
 
 /* Global initialisers */
 
-bool GSocket_Init()
+int GSocket_Init()
 {
-  return TRUE;
+  return 1;
 }
 
 void GSocket_Cleanup()
@@ -92,16 +110,13 @@ GSocket *GSocket_new()
   socket->m_local               = NULL;
   socket->m_peer                = NULL;
   socket->m_error               = GSOCK_NOERROR;
-  socket->m_server              = FALSE;
-  socket->m_stream              = TRUE;
+  socket->m_server              = 0;
+  socket->m_stream              = 1;
   socket->m_gui_dependent       = NULL;
-  socket->m_non_blocking        = FALSE;
+  socket->m_non_blocking        = 0;
   socket->m_timeout             = 10*60*1000;
                                 /* 10 minutes * 60 sec * 1000 millisec */
-  socket->m_establishing        = FALSE;
-
-  /* We initialize the GUI specific entries here */
-  _GSocket_GUI_Init(socket);
+  socket->m_establishing        = 0;
 
   return socket;
 }
@@ -114,9 +129,6 @@ void GSocket_destroy(GSocket *socket)
   if (socket->m_fd != -1)
     GSocket_Shutdown(socket);
 
-  /* We destroy GUI specific variables */
-  _GSocket_GUI_Destroy(socket);
-
   /* We destroy private addresses */
   if (socket->m_local)
     GAddress_destroy(socket->m_local);
@@ -147,7 +159,7 @@ void GSocket_Shutdown(GSocket *socket)
     socket->m_cbacks[evt] = NULL;
 
   socket->m_detected = 0;
-  _GSocket_Disable_Events(socket);
+  (socket);
 }
 
 /* Address handling */
@@ -266,8 +278,8 @@ GSocketError GSocket_SetServer(GSocket *sck)
   }
 
   /* We always have a stream here  */
-  sck->m_stream = TRUE;
-  sck->m_server = TRUE;
+  sck->m_stream = 1;
+  sck->m_server = 1;
 
   /* Create the socket */
   sck->m_fd = socket(sck->m_local->m_realfamily, SOCK_STREAM, 0);
@@ -278,7 +290,6 @@ GSocketError GSocket_SetServer(GSocket *sck)
   }
 
   ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(int));
-  _GSocket_Enable_Events(sck);
 
   /* Bind the socket to the LOCAL address */
   if (bind(sck->m_fd, sck->m_local->m_addr, sck->m_local->m_len) < 0) {
@@ -349,13 +360,11 @@ GSocket *GSocket_WaitConnection(GSocket *socket)
   }
 
   /* Initialize all fields */
-  connection->m_server   = FALSE;
-  connection->m_stream   = TRUE;
-  connection->m_oriented = TRUE;
+  connection->m_server   = 0;
+  connection->m_stream   = 1;
+  connection->m_oriented = 1;
 
   ioctl(connection->m_fd, FIONBIO, (char*)&arg, sizeof(int));
-  _GSocket_Enable_Events(connection);
-
   return connection;
 }
 
@@ -377,9 +386,9 @@ GSocketError GSocket_SetNonOriented(GSocket *sck)
     return GSOCK_INVADDR;
   }
 
-  sck->m_stream   = FALSE;
-  sck->m_server   = FALSE;
-  sck->m_oriented = FALSE;
+  sck->m_stream   = 0;
+  sck->m_server   = 0;
+  sck->m_oriented = 0;
 
   /* Create the socket */
   sck->m_fd = socket(sck->m_local->m_realfamily, SOCK_DGRAM, 0);
@@ -390,7 +399,6 @@ GSocketError GSocket_SetNonOriented(GSocket *sck)
   }
 
   ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(int));
-  _GSocket_Enable_Events(sck);
 
   /* Bind it to the LOCAL address */
   if (bind(sck->m_fd, sck->m_local->m_addr, sck->m_local->m_len) < 0) {
@@ -438,9 +446,9 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
 
   /* Test whether we want the socket to be a stream (e.g. TCP) */
   sck->m_stream   = (stream == GSOCK_STREAMED);
-  sck->m_oriented = TRUE;
-  sck->m_server   = FALSE;
-  sck->m_establishing = FALSE;
+  sck->m_oriented = 1;
+  sck->m_server   = 0;
+  sck->m_establishing = 0;
 
   if (sck->m_stream)
     type = SOCK_STREAM;
@@ -456,7 +464,6 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
   }
 
   ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(int));
-  _GSocket_Enable_Events(sck);
 
   /* Connect it to the PEER address */
   ret = connect(sck->m_fd, sck->m_peer->m_addr, sck->m_peer->m_len);
@@ -496,7 +503,7 @@ GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
     if ((err == EINPROGRESS) && (sck->m_non_blocking))
     {
       sck->m_error = GSOCK_WOULDBLOCK;
-      sck->m_establishing = TRUE;
+      sck->m_establishing = 1;
       fprintf(stderr, "Nonblocking connect in progress\n");
 
       return GSOCK_WOULDBLOCK;
@@ -613,7 +620,7 @@ GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
  *  Sets the socket to non-blocking mode. This is useful if
  *  we don't want to wait.
  */
-void GSocket_SetNonBlocking(GSocket *socket, bool non_block)
+void GSocket_SetNonBlocking(GSocket *socket, int non_block)
 {
   assert(socket != NULL);
 
@@ -714,13 +721,12 @@ void GSocket_UnsetCallback(GSocket *socket, GSocketEventFlags flags)
 void _GSocket_Enable(GSocket *socket, GSocketEvent event)
 {
   socket->m_detected &= ~(1 << event);
-  _GSocket_Install_Callback(socket, event);
+  (socket, event);
 }
 
 void _GSocket_Disable(GSocket *socket, GSocketEvent event)
 {
   socket->m_detected |= (1 << event);
-  _GSocket_Uninstall_Callback(socket, event);
 }
 
 /* _GSocket_Input_Timeout:
@@ -885,7 +891,7 @@ void _GSocket_Detected_Write(GSocket *socket)
   {
     int error, len;
 
-    socket->m_establishing = FALSE;
+    socket->m_establishing = 0;
 
     len = sizeof(error);
     getsockopt(socket->m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);
@@ -1108,6 +1114,11 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
   return GSOCK_NOERROR;
 }
 
+GSocketError GAddress_INET_SetAnyAddress(GAddress *address)
+{
+  return GAddress_INET_SetHostAddress(address, INADDR_ANY);
+}
+
 GSocketError GAddress_INET_SetHostAddress(GAddress *address,
                                           unsigned long hostaddr)
 {
@@ -1217,5 +1228,32 @@ unsigned short GAddress_INET_GetPort(GAddress *address)
   return ntohs(addr->sin_port);
 }
 
+/*
+ * -------------------------------------------------------------------------
+ * Unix address family
+ * -------------------------------------------------------------------------
+ */
+
+GSocketError _GAddress_Init_UNIX(GAddress *address)
+{
+  assert (address != NULL);
+  address->m_error = GSOCK_INVADDR;
+  return GSOCK_INVADDR;
+}
+
+GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path)
+{
+  assert (address != NULL);
+  address->m_error = GSOCK_INVADDR;
+  return GSOCK_INVADDR;
+}
+
+GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf)
+{
+  assert (address != NULL);
+  address->m_error = GSOCK_INVADDR;
+  return GSOCK_INVADDR;
+}
+
 #endif
   /* wxUSE_SOCKETS */