X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b662c13583d9fc10d7b912fb246b8f632339a279..72c71d39724af116d419295b684dd2946efb3da3:/src/os2/gsocket.c diff --git a/src/os2/gsocket.c b/src/os2/gsocket.c index db5644dad7..98ef0f6a04 100644 --- a/src/os2/gsocket.c +++ b/src/os2/gsocket.c @@ -30,14 +30,17 @@ #else #include #include +#include #include #include #include #endif #if defined(__VISAGECPP__) && __IBMCPP__ < 400 +#include #include #include #include +#include #else #include #include @@ -57,7 +60,12 @@ int _System soclose(int); #include #include -#include +#if defined(__VISAGECPP__) && __IBMCPP__ < 400 +# ifdef min +# undef min +# endif +# include +#endif #include #include @@ -80,9 +88,9 @@ int _System soclose(int); /* Global initialisers */ -bool GSocket_Init() +int GSocket_Init() { - return TRUE; + return 1; } void GSocket_Cleanup() @@ -110,16 +118,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; } @@ -132,9 +137,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); @@ -165,7 +167,7 @@ void GSocket_Shutdown(GSocket *socket) socket->m_cbacks[evt] = NULL; socket->m_detected = 0; - _GSocket_Disable_Events(socket); + (socket); } /* Address handling */ @@ -284,8 +286,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); @@ -296,7 +298,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) { @@ -367,13 +368,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; } @@ -395,9 +394,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); @@ -408,7 +407,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) { @@ -456,9 +454,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; @@ -474,7 +472,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); @@ -514,7 +511,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; @@ -631,7 +628,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); @@ -732,13 +729,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: @@ -903,7 +899,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); @@ -1167,7 +1163,7 @@ GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port, port_int = atoi(port); addr = (struct sockaddr_in *)address->m_addr; - addr->sin_port = htons(port_int); +// addr->sin_port = htons(port_int); return GSOCK_NOERROR; } @@ -1189,7 +1185,7 @@ GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port) CHECK_ADDRESS(address, INET, GSOCK_INVADDR); addr = (struct sockaddr_in *)address->m_addr; - addr->sin_port = htons(port); +// addr->sin_port = htons(port); return GSOCK_NOERROR; } @@ -1237,7 +1233,7 @@ unsigned short GAddress_INET_GetPort(GAddress *address) CHECK_ADDRESS(address, INET, 0); addr = (struct sockaddr_in *)address->m_addr; - return ntohs(addr->sin_port); + return /*ntohs*/(addr->sin_port); } /*