Index: trunk/src/wsock32/notify.cpp
===================================================================
--- trunk/src/wsock32/notify.cpp	(revision 517)
+++ trunk/src/wsock32/notify.cpp	(revision 518)
@@ -1,3 +1,3 @@
-/* $Id: notify.cpp,v 1.2 1999-06-10 16:11:08 phaller Exp $ */
+/* $Id: notify.cpp,v 1.3 1999-08-16 20:18:39 phaller Exp $ */
 
 /*
@@ -5,6 +5,4 @@
  * Project Odin Software License can be found in LICENSE.TXT
  *
- */
-/*
  * Winsock code
  *
@@ -14,7 +12,17 @@
 
 
+/*****************************************************************************
+ * Includes                                                                  *
+ *****************************************************************************/
+
 #include <os2win.h>
 //#include <wsock32.h>
-#include "misc.h"
+#include <misc.h>
+#include <odinwrap.h>
+
+
+/*****************************************************************************
+ * Structures                                                                *
+ *****************************************************************************/
 
 typedef unsigned int    u_int;
@@ -37,8 +45,13 @@
 
 
+/*****************************************************************************
+ * Macros                                                                    *
+ *****************************************************************************/
+
 /*
  * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
  * when constructing the response to WSAAsyncSelect().
  */
+
 //#define OS2WSAMAKESELECTREPLY(event,error)     MAKELONG(event,error)
 #ifdef MAKELONG
@@ -48,8 +61,11 @@
 #define OS2WSAMAKESELECTREPLY(event,error)     MAKELONG(event,error)
 
+
+
+
 int Notify(AsyncStatus *as, int event)
 {
-int rc;
-    
+  int rc;
+
 #ifdef DEBUG
     WriteLog("WSOCK32: Open32 Notifying %x, %x, %d\n",
@@ -80,2 +96,3 @@
 
 
+
Index: trunk/src/wsock32/unknown.cpp
===================================================================
--- trunk/src/wsock32/unknown.cpp	(revision 517)
+++ trunk/src/wsock32/unknown.cpp	(revision 518)
@@ -1,3 +1,3 @@
-/* $Id: unknown.cpp,v 1.1 1999-07-07 12:18:04 phaller Exp $ */
+/* $Id: unknown.cpp,v 1.2 1999-08-16 20:18:40 phaller Exp $ */
 
 /*
@@ -14,5 +14,8 @@
 #include <os2wrap.h>
 #include <misc.h>
+#include <odinwrap.h>
 
+
+ODINDEBUGCHANNEL(WSOCK32-UNKNOWN)
 
 /*****************************************************************************
@@ -25,6 +28,6 @@
 
 /*****************************************************************************
- * Name      : int WIN32API OS2rexec
- * Purpose   :
+ *
+ * Purpose,  :
  * Parameters:
  * Variables :
@@ -36,18 +39,12 @@
  *****************************************************************************/
 
-int WIN32API OS2rexec(LPSTR *lppArg1,
-                      int   iArg2,
-                      LPSTR lpArg3,
-                      LPSTR lpArg4,
-                      LPSTR lpArg5,
-                      int   *lpiArg6)
+ODINFUNCTION6(int, OS2rexec, LPSTR*, lppArg1,
+                             int,    iArg2,
+                             LPSTR,  lpArg3,
+                             LPSTR,  lpArg4,
+                             LPSTR,  lpArg5,
+                             int*,   lpiArg6)
 {
-  dprintf(("WSOCK32: OS2rexec(%08xh,%08xh,%s,%s,%s,%08xh) not implemented correctly.\n",
-           lppArg1,
-           iArg2,
-           lpArg3,
-           lpArg4,
-           lpArg5,
-           lpiArg6));
+  dprintf(("WSOCK32: OS2rexec not implemented correctly.\n"));
 
   return rexec(lppArg1,
@@ -61,8 +58,8 @@
 
 /*****************************************************************************
- * Name      : int WIN32API OS2rcmd
- * Purpose   :
- * Parameters:
- * Variables :
+ * ODINFUNCTION6( :, int, WIN32API, OS2rcmd,
+ * Purpose, :,
+ * Parameters:,
+ * Variables, :,
  * Result    :
  * Remark    : WSOCK32.1103
@@ -72,18 +69,12 @@
  *****************************************************************************/
 
-int WIN32API OS2rcmd(LPSTR      *lppArg1,
-                     int        iArg2,
-                     const char *lpArg3,
-                     const char *lpArg4,
-                     const char *lpArg5,
-                     int        *lpiArg6)
+ODINFUNCTION6(int, OS2rcmd, LPSTR*,     lppArg1,
+                            int,        iArg2,
+                            const char*,lpArg3,
+                            const char*,lpArg4,
+                            const char*,lpArg5,
+                            int       *,lpiArg6)
 {
-  dprintf(("WSOCK32: OS2rcmd(%08xh,%08xh,%s,%s,%s,%08xh) not implemented.\n",
-           lppArg1,
-           iArg2,
-           lpArg3,
-           lpArg4,
-           lpArg5,
-           lpiArg6));
+  dprintf(("WSOCK32: rcmd not implemented.\n"));
 
   //@@@PH actually it exists in TCP/IP 5.0 headers. Unknown which OS/2 function to link to.
@@ -99,2 +90,3 @@
 }
 
+
Index: trunk/src/wsock32/wsock32.cpp
===================================================================
--- trunk/src/wsock32/wsock32.cpp	(revision 517)
+++ trunk/src/wsock32/wsock32.cpp	(revision 518)
@@ -1,3 +1,3 @@
-/* $Id: wsock32.cpp,v 1.3 1999-06-19 10:54:48 sandervl Exp $ */
+/* $Id: wsock32.cpp,v 1.4 1999-08-16 20:18:40 phaller Exp $ */
 
 /*
@@ -5,14 +5,18 @@
  * Project Odin Software License can be found in LICENSE.TXT
  *
+ * Win32 SOCK32 for OS/2
+ *
+ * 1998/08/25 Vince Vielhaber
+ *
+ * @(#) wsock32.c                        1.0.0   1998/08/25 VV initial release
+ *                      1.0.1   1999/04/27 VV cleanup and implement select.
+ *
  */
-/*
- * Win32 SOCK32 for OS/2
- *
- * 1998/08/25 Vince Vielhaber
- *
- * @(#) wsock32.c     	1.0.0   1998/08/25 VV initial release
- *                      1.0.1   1999/04/27 VV cleanup and implement select.
- *
- */
+
+
+/*****************************************************************************
+ * Includes                                                                  *
+ *****************************************************************************/
+
 
 #define INCL_DOSPROCESS     /* Process and thread values */
@@ -32,5 +36,5 @@
 #endif
 
-#include <os2wrap.h>	//Odin32 OS/2 api wrappers
+#include <os2wrap.h>                     //Odin32 OS/2 api wrappers
 #include <stdio.h>
 #include <stdlib.h>
@@ -39,4 +43,5 @@
 #include <ctype.h>
 #include <types.h>
+#include <odinwrap.h>
 #include <netdb.h>
 #include <sys/socket.h>
@@ -54,35 +59,96 @@
 
 
-#define FAR
-//#define WIN32API APIENTRY
+ODINDEBUGCHANNEL(WSOCK32-WSOCK32)
+
+
+/*****************************************************************************
+ * Defines                                                                   *
+ *****************************************************************************/
+
+#define GETSERVBYNAME    1
+#define GETSERVBYPORT    2
+#define GETPROTOBYNAME   3
+#define GETPROTOBYNUMBER 4
+#define GETHOSTBYNAME    5
+#define GETHOSTBYADDR    6
+
+#define BLOCKING 0
+#define NONBLOCKING 1
+
+#ifdef FD_CLR
+#undef FD_CLR
+#define FD_CLR(x,y) WFD_CLR(x,y)
+#undef FD_SET
+#define FD_SET(x,y) WFD_SET(x,y)
+#undef FD_ZERO
+#define FD_ZERO(x) WFD_ZERO(x)
+#undef FD_ISSET
+#define FD_ISSET(x,y) WFD_SET(x,y)
+#endif
+
+
+/*****************************************************************************
+ * Structures                                                                *
+ *****************************************************************************/
+
+typedef struct WSAStruct
+{
+  int CallingWhat;
+  HWND hw;
+  u_int msg;
+  char *carg1;
+  char *carg2;
+  int iarg1;
+  int iarg2;
+  char *buf;
+  int buflen;
+} WSAStruct;
+
+typedef struct PipeStruct
+{
+  AsyncStatus as;
+  int MsgLoop;
+  HFILE rcv;
+  HFILE snd;
+} PipeStruct;
+
+typedef struct sockaddr* PSOCKADDR;
+
+//typedef struct _TRANSMIT_FILE_BUFFERS {
+//    PVOID Head;
+//    DWORD HeadLength;
+//    PVOID Tail;
+//    DWORD TailLength;
+//} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
+//
+//BOOL, OS2TransmitFile, //, IN, SOCKET, hSocket, //, IN, HANDLE, hFile, //, IN, DWORD, nNumberOfBytesToWrite, //, IN DWORD nNumberOfBytesPerSend,
+//    IN LPOVERLAPPED lpOverlapped,
+//    IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
+//    IN DWORD dwReserved)
+//{
+//    return FALSE;
+//}
+
+
+/*****************************************************************************
+ * Prototypes                                                                *
+ *****************************************************************************/
+
+void _System AsyncLoop             (ULONG);
+void         CheckThreads          (AsyncStatus *);
+void         NotifyApp             (int,AsyncStatus *);
+int          Notify                (AsyncStatus *,int);
+int          NotifyWSA             (HWND hw,u_int msg,UINT wp,LONG lp);
+void _System WSAFunct              (ULONG); // for the wsa database calls
+void         SetErrForDatabaseCalls(void);
+
+
+/*****************************************************************************
+ * Local variables                                                           *
+ *****************************************************************************/
 
 static WHOSTENT whsnt;
 static WSERVENT wsvnt;
 static WPROTOENT wptnt;
-
- /*+-------------------------------------------------------------------+*/
- /*| _CRT_init is the C run-time environment initialization function.  |*/
- /*|It will return 0 to indicate success and -1 to indicate failure.   |*/
- /*+-------------------------------------------------------------------+*/
- 
-int _CRT_init (void);
- 
- /*+-------------------------------------------------------------------+*/
- /*| _CRT_term is the C run-time environment termination function.     |*/
- /*+-------------------------------------------------------------------+*/
- 
-void _CRT_term (unsigned long);
-
-void _System AsyncLoop(ULONG);
-void CheckThreads(AsyncStatus *);
-void NotifyApp(int,AsyncStatus *);
-int Notify(AsyncStatus *,int);
-
-int NotifyWSA(HWND hw,u_int msg,UINT wp,LONG lp);
-
-void _System WSAFunct(ULONG); // for the wsa database calls
-void SetErrForDatabaseCalls(void);
-
-
 size_t nSize;
 int *pArray;
@@ -91,10 +157,12 @@
 int LocalErrorNumber = 0;
 
-
 TID tidAsyncLoop = 0;     /* ID of AsyncSelect (AsyncLoop) thread */
 
+PipeStruct PS;
+
+AsyncStatus *TopASY = 0;
+
+
 /*
-
- 
 typedef struct AsyncStatus {
     HWND hwnd;     // owner's hwindow
@@ -108,641 +176,1133 @@
     struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list
 } AsyncStatus;
- 
- 
- 
 */
 
-AsyncStatus *TopASY = 0;
-
-
-#define BLOCKING 0
-#define NONBLOCKING 1
-
-
-
-typedef struct WSAStruct {
-    int CallingWhat;
-    HWND hw;
-    u_int msg;
-    char *carg1;
-    char *carg2;
-    int iarg1;
-    int iarg2;
-    char *buf;
-    int buflen;
-} WSAStruct;
-
-
-#define GETSERVBYNAME    1
-#define GETSERVBYPORT    2
-#define GETPROTOBYNAME   3
-#define GETPROTOBYNUMBER 4
-#define GETHOSTBYNAME    5
-#define GETHOSTBYADDR    6
-
-
-
-
-typedef struct PipeStruct {
-    AsyncStatus as;
-    int MsgLoop;
-    HFILE rcv;
-    HFILE snd;
-} PipeStruct;
-
-PipeStruct PS;
-
-
-
-#ifdef FD_CLR
-#undef FD_CLR
-#define FD_CLR(x,y) WFD_CLR(x,y)
-#undef FD_SET
-#define FD_SET(x,y) WFD_SET(x,y)
-#undef FD_ZERO
-#define FD_ZERO(x) WFD_ZERO(x)
-#undef FD_ISSET
-#define FD_ISSET(x,y) WFD_SET(x,y)
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+void _System AsyncLoop(ULONG ASP)
+{
+  int socks[1],r,w,e,rc,ii;
+  AsyncStatus *as;
+
+  as = (AsyncStatus *)ASP;
+
+  r = w = e = 0;
+  if(as->event & FD_READ) r = 1;
+  if(as->event & FD_WRITE) w = 1;
+  if(as->event & FD_OOB) e = 1;
+
+  socks[0] = (int)as->socket;
+
+  if((r+w+e) == 0)
+  {
+    dprintf(("WSOCK32: Turning off async\n"));
+
+    ii = 0;
+    rc = ioctl(socks[0],FIONBIO,(char *)&ii,sizeof(ii));
+    as->threadID = 0;
+    as->hwnd = 0;
+    as->msg = 0;
+    as->event = 0;
+    as->status = BLOCKING;
+    return;
+  } // end if
+  else
+  {
+    dprintf(("WSOCK32: Setting up non-blocking sockets\n"));
+    ii = 1;
+    rc = ioctl(socks[0],FIONBIO,(char *)&ii,sizeof(ii));
+    if(rc != 0)
+    {
+      dprintf(("WSOCK32: ioctl failed trying to non-block.\n"));
+      return;
+    }
+    as->status = NONBLOCKING;
+  } // end else
+
+  do
+  {
+    rc = select(socks[0],(fd_set*)&r,0,0,0); // ioctl may be better for this.
+    if(rc > 0)
+    {
+      rc = ioctl(socks[0],FIONREAD,(char *)&ii,sizeof(ii));
+      if(rc == 0 && ii > 0)
+      {
+        /* data is ready */
+        NotifyApp(FD_READ,as);
+      }
+    }
+
+    if(rc < 0)
+    {
+      rc = sock_errno();
+      /* something ain't right */
+      if(rc == 10038)
+      { // Connection closed
+        NotifyApp(FD_CLOSE,as);
+        DosSleep(500);
+        return;
+      }
+
+      dprintf(("WSOCK32: Select error: %d\n",
+               rc));
+    } // end if
+    DosSleep(50);
+  }
+  while(1);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+void CheckThreads(AsyncStatus *as)
+{
+  AsyncStatus *asy;
+
+  if(as != NULL)
+    if(as->threadID != 0) DosKillThread(as->threadID);
+
+  for(asy = TopASY; asy; asy = asy->Next)
+    if(asy->threadID != 0)
+      DosKillThread(asy->threadID);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+void NotifyApp(int xx,AsyncStatus *as)
+{
+  BOOL    fResult;        /* message-posted indicator             */
+  unsigned long ii;
+
+
+//#ifdef DEBUG
+//    WriteLog("WSOCK32: Notifying the caller.  rc = %d\n",xx);
+//#endif
+
+  if(as->MsgStat == 0)
+  {
+   fResult = Notify(as,xx);
+   dprintf(("WSOCK32: Notify returns: %d\n",
+            fResult));
+  } // end if
+
+  if(as->MsgStat == 2)
+    as->MsgStat = 0;
+  else
+    as->MsgStat = 1;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+void _System WSAFunct(ULONG xx)
+{
+  WSAStruct *wsa;
+  WSERVENT *ooo;
+  char *yy;
+  int ii;
+  size_t ss;
+  UINT wp;
+  LONG lp;
+  int id = *_threadid;
+
+  wsa = (WSAStruct *)xx;
+
+  dprintf(("WSOCK32: WSAFunct: xx = %p, hwnd = %p\n",
+           xx,
+           wsa->hw));
+
+  dprintf(("WSOCK32: WSAFunct info carg1 = %s, carg2 = %s\n",
+           wsa->carg1,
+           wsa->carg2));
+
+  dprintf(("WSOCK32: WSAFunct info buf = %p, %d\n",
+           wsa->buf,
+           wsa->buflen));
+
+  switch (wsa->CallingWhat)
+  {
+    case GETSERVBYNAME:
+      yy = (char *)OS2getservbyname(wsa->carg1,wsa->carg2);
+      ss = sizeof(WSERVENT);
+      break;
+    case GETSERVBYPORT:
+      yy = (char *)OS2getservbyport(wsa->iarg1,wsa->carg1);
+      break;
+    case GETPROTOBYNUMBER:
+      yy = (char *)OS2getprotobynumber(wsa->iarg1);
+      break;
+    case GETPROTOBYNAME:
+      yy = (char *)OS2getprotobyname(wsa->carg1);
+      break;
+    case GETHOSTBYNAME:
+      yy = (char *)OS2gethostbyname(wsa->carg1);
+      break;
+    case GETHOSTBYADDR:
+      yy = (char *)OS2gethostbyaddr(wsa->carg1,wsa->iarg1,wsa->iarg2);
+      break;
+    default:
+      yy = (char *)NULL;
+      OS2WSASetLastError(-5000);
+      break;
+  } // end switch
+
+#ifdef DEBUG
+  if(yy)
+  {
+    ooo = (WSERVENT *)yy;
+    dprintf(("WSOCK32: WSAFunct service name = %s, port = %d\n",
+             ooo->s_name,
+             (int)ooo->s_port));
+  }
 #endif
 
-
-
-
-
-
-int WIN32API OS2__WSAFDIsSet(SOCKET fd, Wfd_set FAR *set) 
-{
-int i = set->fd_count;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: __WSAFDIsSet\n");
+  wp = id;
+
+  if(yy == (char *)NULL)
+  {
+    dprintf(("WSOCK32: WSAFunct error carg1 = %s, carg2 = %s\n",
+             wsa->carg1,
+             wsa->carg2));
+
+   ii = OS2WSAGetLastError();
+   lp = OS2WSAMAKEASYNCREPLY(0,ii);
+  } // end if
+  else
+  {
+    if(wsa->buflen < ss)
+      ii = WSAENOBUFS;
+    else
+      ii = 0;
+
+    lp = OS2WSAMAKEASYNCREPLY(ss,ii);
+    if(ii == 0)
+      memmove(wsa->buf,yy,ss);
+  }
+
+  do
+  {
+    if(WinQueryAnchorBlock(wsa->hw))
+          ii = NotifyWSA(wsa->hw,wsa->msg,wp,lp);
+  } while(ii != TRUE);
+
+  free(wsa);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+void SetErrForDatabaseCalls(void)
+{
+  switch(h_errno)
+  {
+    case 1:
+      OS2WSASetLastError(11001); // host not found
+      break;
+    case 2:
+      OS2WSASetLastError(11002); // try again later
+      break;
+    case 3:
+      OS2WSASetLastError(11003); // No recovery
+      break;
+    case 4:
+      OS2WSASetLastError(11004); // No address or no data
+      break;
+    default:
+      OS2WSASetLastError(0); // unknown error and should never get here
+      dprintf(("WSOCK32: Unknown error condition: %d\n",
+               h_errno));
+      break;
+  }
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+AsyncStatus * FindASY(SOCKET s)
+{
+  AsyncStatus *as;
+
+  for(as = TopASY; as; as = as->Next)
+    if(as->socket == s)
+      return as;
+
+  return 0;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(int, OS2__WSAFDIsSet, SOCKET,       fd,
+                                    Wfd_set FAR*, set)
+{
+  int i = set->fd_count;
+
+  while (i--)
+    if (set->fd_array[i] == fd)
+      return 1;
+
+  return 0;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(SOCKET,OS2accept,SOCKET,    s,
+                               PSOCKADDR, addr,
+                               int*,      addrlen)
+{
+  return accept(s,addr,addrlen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(int,OS2bind,SOCKET,          s,
+                          const struct sockaddr *, addr,
+                          int,             namelen)
+{
+  return bind(s,(PSOCKADDR)addr,namelen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(int,OS2closesocket,SOCKET,s)
+{
+  AsyncStatus *as;
+
+  as = FindASY(s);
+  if(as == NULL)
+  {
+    LocalErrorNumber = 10038;
+    return -1;
+  }
+
+  CheckThreads(as);
+
+  if(as->Prev && as->Next)
+    as->Prev->Prev = as->Next->Next; // I SURE HOPE THIS IS RIGHT!!!!!!!!
+
+  free(as);
+
+  return soclose((int)s);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(int,OS2connect,SOCKET,          s,
+                             const struct sockaddr*, name,
+                             int,             namelen)
+{
+  return connect(s,
+                 (PSOCKADDR)name,
+                 namelen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(int,OS2ioctlsocket,SOCKET,  s,
+                                 long,    cmd,
+                                 u_long*, argp)
+{
+  return ioctl(s, cmd, (char *)argp, 4);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(int,OS2getpeername,SOCKET,   s,
+                                 PSOCKADDR,name,
+                                 int*,     namelen)
+{
+  return getpeername(s,name,namelen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(int,OS2getsockname,SOCKET,   s,
+                                 PSOCKADDR,name,
+                                 int*,     namelen)
+{
+  return getsockname(s,name,namelen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(int,OS2getsockopt,SOCKET,s,
+                                int,   level,
+                                int,   optname,
+                                char*, optval,
+                                int*,  optlen)
+{
+  return getsockopt(s,level,optname,optval,optlen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(u_long,OS2htonl,u_long,hostlong)
+{
+  return htonl(hostlong);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(u_short,OS2htons,u_short,hostshort)
+{
+  return htons(hostshort);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(u_long,OS2inet_addr,const char*, cp)
+{
+  return inet_addr((char *)cp);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(char*,OS2inet_ntoa,struct in_addr,in)
+{
+  return inet_ntoa(in);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(int,OS2listen,SOCKET,s,
+                            int,   backlog)
+{
+  return listen(s,backlog);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(u_long,OS2ntohl,u_long,netlong)
+{
+  return ntohl(netlong);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(u_short,OS2ntohs,u_short,netshort)
+{
+  return ntohs(netshort);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION4(int,OS2recv,SOCKET,s,
+                          char*, buf,
+                          int,   len,
+                          int,   flags)
+{
+  unsigned long ii;
+  int           xx,
+                yy;
+  char          buff[200];
+  AsyncStatus   *as;
+
+  PS.MsgLoop = 0;
+
+  as = FindASY(s);
+
+  if(as != NULL)
+    as->MsgStat = 2;
+
+  xx = recv(s,buf,len,flags);
+
+  return xx;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION6(int,OS2recvfrom,SOCKET,    s,
+                              char*,     buf,
+                              int,       len,
+                              int,       flags,
+                              PSOCKADDR, from,
+                              int*,      fromlen)
+{
+  return recvfrom(s,buf,len,flags,from,fromlen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+#ifdef VV_BSD_SELECT
+
+ODINFUNCTION5(int,OS2select,int,      nfds,
+                            Wfd_set*, readfds,
+                            Wfd_set*, writefds,
+                            Wfd_set*, exceptfds,
+                            const struct Wtimeval*, timeout)
+{
+  return select(nfds,
+                (fd_set *)readfds,
+                (fd_set *)writefds,
+                (fd_set *)exceptfds,
+                (timeval *)timeout);
+}
+
+#else
+#  error OS/2-style select not implemented!
 #endif
- 
-     while (i--)
-         if (set->fd_array[i] == fd)
-             return 1;
- 
-return 0;
-}
-
-
-
-AsyncStatus * FindASY(SOCKET s)
-{
-AsyncStatus *as;
-
-    for(as = TopASY; as; as = as->Next)
-        if(as->socket == s)
-            return as;
-
-return 0;
-}
-
-
-
-SOCKET WIN32API OS2accept (SOCKET s, struct sockaddr *addr,
-                        int *addrlen) {
-#ifdef DEBUG
-    WriteLog("WSOCK32: accept\n");
-#endif
-
-    return accept(s,addr,addrlen);
-}
-
-int WIN32API OS2bind (SOCKET s, const struct sockaddr *addr, int namelen)
-{
- int rc;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: bind\n");
-#endif
-
-    rc = bind(s,(struct sockaddr *)addr,namelen);
-    dprintf(("bind returned %X\n", rc));
-    return(rc);
-}
-
-int WIN32API OS2closesocket (SOCKET s)
-{
-AsyncStatus *as;
-#ifdef DEBUG
-    WriteLog("WSOCK32: closesocket\n");
-#endif
-
-    as = FindASY(s);
-    if(as == NULL) {
-        LocalErrorNumber = 10038;
-        return -1;
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION4(int,OS2send,SOCKET,      s,
+                          const char*, buf,
+                          int,         len,
+                          int,         flags)
+{
+  return send(s,(char *)buf,len,flags);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION6(int,OS2sendto,SOCKET,          s,
+                            const char*,     buf,
+                            int,             len,
+                            int,             flags,
+                            const struct sockaddr*, to,
+                            int,             tolen)
+{
+  return sendto(s,(char *)buf,len,flags,(PSOCKADDR)to,tolen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(int,OS2setsockopt,SOCKET,      s,
+                                int,         level,
+                                int,         optname,
+                                const char*, optval,
+                                int,         optlen)
+{
+  struct Wlinger *yy;
+  struct linger xx;
+
+  if(level   == SOL_SOCKET &&
+     optname == SO_LINGER)
+  {
+    yy = (struct Wlinger *)optval;
+    xx.l_onoff = (int)yy->l_onoff;
+    xx.l_linger = (int)yy->l_linger;
+
+    return setsockopt(s,level,optname,(char *)&xx,optlen);
+  }
+  else
+    return setsockopt(s,level,optname,(char *)optval,optlen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(int,OS2shutdown,SOCKET,s,
+                              int,   how)
+{
+  return shutdown(s,how);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(SOCKET,OS2socket,int,af,
+                               int,type,
+                               int,protocol)
+{
+  SOCKET s;
+  AsyncStatus *as;
+
+  s = (SOCKET)socket(af,type,protocol);
+  if(s > 0)
+  {
+    as = (AsyncStatus *)malloc(sizeof(AsyncStatus));
+    if(as != NULL)
+    {
+      as->hwnd = (HWND)0;
+      as->msg = 0;
+      as->event = 0L;
+      as->socket = s;
+      as->status = BLOCKING;
+      as->threadID = 0;
+      as->MsgStat = 0;
+      as->Next = TopASY;
+      as->Prev = NULL;
+
+      if(TopASY)
+        TopASY->Prev = as;
+
+      TopASY = as;
     }
-
-    CheckThreads(as);
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: closesocket\n");
-#endif
-    if(as->Prev && as->Next)
-        as->Prev->Prev = as->Next->Next; // I SURE HOPE THIS IS RIGHT!!!!!!!!
-    free(as);
-    
-    return soclose((int)s);
-}
-
-int WIN32API OS2connect (SOCKET s, const struct sockaddr *name, int namelen)
-{
-#ifdef DEBUG
-//char message[512];
-//struct Wsockaddr_in *xname;
-
-  WriteLog("WSOCK32: connect\n");
-
-
-#endif
-
-    return connect(s,(struct sockaddr *)name,namelen);
-}
-
-int WIN32API OS2ioctlsocket (SOCKET s, long cmd, u_long *argp)
-{
- int rc;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: ioctlsocket unimplemented\n");
-#endif
-
-    rc = ioctl(s, cmd, (char *)argp, 4);
-    dprintf(("ioctl returned %X\n", rc));
-    return(rc);
-}
-
-int WIN32API OS2getpeername (SOCKET s, struct sockaddr *name,
-                          int * namelen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: getpeername\n");
-#endif
-
-    return getpeername(s,name,namelen);
-}
-
-int WIN32API OS2getsockname (SOCKET s, struct sockaddr *name,
-                          int * namelen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: getsockname\n");
-#endif
-
-    return getsockname(s,name,namelen);
-}
-
-int WIN32API OS2getsockopt (SOCKET s, int level, int optname,
-                         char * optval, int *optlen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: getsockopt\n");
-#endif
-
-    return getsockopt(s,level,optname,optval,optlen);
-}
-
-u_long WIN32API OS2htonl (u_long hostlong)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: htonl\n");
-#endif
-
-    return htonl(hostlong);
-}
-
-u_short WIN32API OS2htons (u_short hostshort)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: htons\n");
-#endif
-
-    return htons(hostshort);
-}
-
-unsigned long WIN32API OS2inet_addr (const char * cp)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: inet_addr\n");
-#endif
-
-    return inet_addr((char *)cp);
-}
-
-char * WIN32API OS2inet_ntoa (struct in_addr in)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: inet_ntoa\n");
-#endif
-
-    return inet_ntoa(in);
-}
-
-int WIN32API OS2listen (SOCKET s, int backlog)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: listen\n");
-#endif
-
-    return listen(s,backlog);
-}
-
-u_long WIN32API OS2ntohl (u_long netlong)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: ntohl\n");
-#endif
-
-    return ntohl(netlong);
-}
-
-u_short WIN32API OS2ntohs (u_short netshort)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: ntohs\n");
-#endif
-
-    return ntohs(netshort);
-}
-
-int WIN32API OS2recv (SOCKET s, char * buf, int len, int flags)
-{
-unsigned long ii;
-int xx,yy;
-char buff[200];
-AsyncStatus *as;
-#ifdef DEBUG
-    WriteLog("WSOCK32: recv socket: %u\n",(unsigned int)s);
-    WriteLog("WSOCK32: recv len: %d\n",len);
-    WriteLog("WSOCK32: recv flags: %d\n",flags);
-
-#endif
-
-    PS.MsgLoop = 0;
-
-    as = FindASY(s);
-
-    if(as != NULL) as->MsgStat = 2;
-
-    
-    xx = recv(s,buf,len,flags);
-
-return xx;
-}
-
-
-
-int WIN32API OS2recvfrom (SOCKET s, char * buf, int len, int flags,
-                       struct sockaddr *from, int * fromlen)
-{
- int rc;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: recvfrom\n");
-#endif
-
-    rc = recvfrom(s,buf,len,flags,from,fromlen);
-    dprintf(("recvfrom returned %X\n", rc));
-    return(rc);
-}
-
-
-
-#ifdef VV_BSD_SELECT
-
-
-int WIN32API OS2select (int nfds, Wfd_set *readfds, Wfd_set *writefds,
-                     Wfd_set *exceptfds, const struct Wtimeval *timeout)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: select\n");
-#endif
-
-
-    return select(nfds,(fd_set *)readfds,(fd_set *)writefds,(fd_set *)exceptfds,(timeval *)timeout);
-    
-}
-
-
-
-#else
-
-
-int WIN32API OS2select (int nfds, Wfd_set *readfds, Wfd_set *writefds,
-                     Wfd_set *exceptfds, const struct Wtimeval *timeout)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: select\n");
-#endif
-
-    // NEED TO DO THIS ONE!!!!!
-    
-    return 0;
-}
-#endif
-
-
-
-int WIN32API OS2send (SOCKET s, const char * buf, int len, int flags)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: send socket: %u\n",(unsigned int)s);
-//    WriteLog("WSOCK32: send buf: %s\n",buf);
-    WriteLog("WSOCK32: send len: %d\n",len);
-    WriteLog("WSOCK32: send flags: %d\n",flags);
-#endif
-
-    return send(s,(char *)buf,len,flags);
-}
-
-int WIN32API OS2sendto (SOCKET s, const char * buf, int len, int flags,
-                     const struct sockaddr *to, int tolen)
-{
- int rc;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: sendto\n");
-#endif
-
-    rc = sendto(s,(char *)buf,len,flags,(struct sockaddr *)to,tolen);
-    dprintf(("sendto returned %X\n", rc));
-    return(rc);
-}
-
-int WIN32API OS2setsockopt (SOCKET s, int level, int optname,
-                         const char * optval, int optlen)
-{
-struct Wlinger *yy;
-struct linger xx;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: setsockopt\n");
-#endif
-
-    if(level == SOL_SOCKET && optname == SO_LINGER) {
-	yy = (struct Wlinger *)optval;
-	xx.l_onoff = (int)yy->l_onoff;
-	xx.l_linger = (int)yy->l_linger;
-
-        return setsockopt(s,level,optname,(char *)&xx,optlen);
-    } 
-
-    else return setsockopt(s,level,optname,(char *)optval,optlen);
-
-}
-
-int WIN32API OS2shutdown (SOCKET s, int how)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: shutdown\n");
-#endif
-
-    return shutdown(s,how);
-}
-
-SOCKET WIN32API OS2socket (int af, int type, int protocol)
-{
-SOCKET s;
-AsyncStatus *as;
-#ifdef DEBUG
-    WriteLog("WSOCK32: socket\n");
-#endif
-
-    s = (SOCKET)socket(af,type,protocol);
-
-    if(s > 0) {
-        as = (AsyncStatus *)malloc(sizeof(AsyncStatus));
-        if(as != NULL) {
-           as->hwnd = (HWND)0;
-           as->msg = 0;
-           as->event = 0L;
-           as->socket = s;
-           as->status = BLOCKING;
-           as->threadID = 0;
-           as->MsgStat = 0;
-           as->Next = TopASY;
-           as->Prev = NULL;
-           if(TopASY) TopASY->Prev = as;
-           TopASY = as;
-        } else {
-            soclose(s);
-            return -1;
-        }
+    else
+    {
+      soclose(s);
+      return -1;
     }
-    dprintf(("WSOCK32: socket returned %X\n", s));
-
-return s;
-}
-
-/* Database function prototypes */
-
-
-void SetErrForDatabaseCalls(void)
-{
-
-    switch(h_errno) {
-        case 1:
-            OS2WSASetLastError(11001); // host not found
-            break;
-        case 2:
-            OS2WSASetLastError(11002); // try again later
-            break;
-        case 3:
-            OS2WSASetLastError(11003); // No recovery
-            break;
-        case 4:
-            OS2WSASetLastError(11004); // No address or no data
-            break;
-        default:
-            OS2WSASetLastError(0); // unknown error and should never get here
-#ifdef DEBUG
-WriteLog("WSOCK32: Unknown error condition: %d\n",h_errno);
-#endif
-            break;
-    }
-
-return;
-}
-
-
-
-
-WHOSTENT * WIN32API OS2gethostbyaddr(const char * addr,
-                                        int len, int type)
-{
-WHOSTENT *yy;
-struct hostent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: gethostbyaddr\n");
-#endif
-
-    xx = gethostbyaddr((char *)addr,len,type);
-
-    if(xx == NULL) {
-        SetErrForDatabaseCalls();
-        return (WHOSTENT *)NULL;
-    }
-
-    whsnt.h_name = xx->h_name;
-    whsnt.h_aliases = xx->h_aliases;
-    whsnt.h_addrtype = (short)xx->h_addrtype;
-    whsnt.h_length = (short)xx->h_length;
-    whsnt.h_addr_list = xx->h_addr_list;
-
-return &whsnt;
-}
-
-
-
-
-WHOSTENT * WIN32API OS2gethostbyname(const char * name)
-{
-WHOSTENT *yy;
-struct hostent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: gethostbyname: %s\n",name);
-#endif
-
-    xx = gethostbyname((char *)name);
-
-    if(xx == NULL) {
-        SetErrForDatabaseCalls();
-        return (WHOSTENT *)NULL;
-    }
-
-    whsnt.h_name = xx->h_name;
-    whsnt.h_aliases = xx->h_aliases;
-    whsnt.h_addrtype = (short)xx->h_addrtype;
-    whsnt.h_length = (short)xx->h_length;
-    whsnt.h_addr_list = xx->h_addr_list;
-  
-return &whsnt;    
-}
-
-
-
-
-
-
-int WIN32API _OS2gethostname (char * name, int namelen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: _gethostname\n");
-#endif
-
-    return gethostname(name,namelen);
-}
-
-
-
-int WIN32API OS2gethostname (char * name, int namelen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: gethostname\n");
-#endif
-
-    return gethostname(name,namelen);
-}
-
-WSERVENT * WIN32API OS2getservbyport(int port, const char * proto)
-{
-struct servent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: getservbyport\n");
-#endif
-
-    xx = getservbyport(port,(char *)proto);
-
-    if(xx == NULL) { // this call doesn't generate an error message
-        return (WSERVENT *)NULL;
-    }
-
-    wsvnt.s_name = xx->s_name;
-    wsvnt.s_aliases = xx->s_aliases;
-    wsvnt.s_port = (short)xx->s_port;
-    wsvnt.s_proto = xx->s_proto;
-
-return &wsvnt;
-}
-
-WSERVENT * WIN32API OS2getservbyname(const char * name,
-                                        const char * proto)
-{
-WSERVENT *yy;
-struct servent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: getservbyname\n");
-#endif
-
-    xx = getservbyname((char *)name,(char *)proto);
-
-    if(xx == NULL) { // this call doesn't generate an error message
-      return (WSERVENT *)NULL;
-    }
-
-    wsvnt.s_name = xx->s_name;
-    wsvnt.s_aliases = xx->s_aliases;
-    wsvnt.s_port = (short)xx->s_port;
-    wsvnt.s_proto = xx->s_proto;
-
-return &wsvnt;
-}
-
-WPROTOENT * WIN32API OS2getprotobynumber(int proto)
-{
-struct protoent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: getprotobynumber\n");
-#endif
-
-    xx = getprotobynumber(proto);
-
-    if(xx == NULL) { // this call doesn't generate an error message
-        return (WPROTOENT *)NULL;
-    }
-
-    wptnt.p_name = xx->p_name;
-    wptnt.p_aliases = xx->p_aliases;
-    wptnt.p_proto = (short)xx->p_proto;
-
-return &wptnt;
-}
-
-WPROTOENT * WIN32API OS2getprotobyname(const char * name)
-{
-struct protoent *xx;
-#ifdef DEBUG
-    WriteLog("WSOCK32: getprotobyname\n");
-#endif
-
-    xx = getprotobyname((char *)name);
-
-    if(xx == NULL) { // this call doesn't generate an error message
-        return (WPROTOENT *)NULL;
-    }
-
-    wptnt.p_name = xx->p_name;
-    wptnt.p_aliases = xx->p_aliases;
-    wptnt.p_proto = (short)xx->p_proto;
-
-return &wptnt;
-}
-
-
-
-
-int WIN32API OS2WSAStartup(USHORT wVersionRequired, LPWSADATA lpWsaData)
-{
-APIRET rc;
-int ii;
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAStartup\n");
-#endif
+  }
+
+  return s;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION3(WHOSTENT*,OS2gethostbyaddr,const char*, addr,
+                                         int,         len,
+                                         int,         type)
+{
+  WHOSTENT *yy;
+  struct hostent *xx;
+
+  xx = gethostbyaddr((char *)addr,len,type);
+
+  if(xx == NULL)
+  {
+     SetErrForDatabaseCalls();
+     return (WHOSTENT *)NULL;
+  }
+
+  whsnt.h_name = xx->h_name;
+  whsnt.h_aliases = xx->h_aliases;
+  whsnt.h_addrtype = (short)xx->h_addrtype;
+  whsnt.h_length = (short)xx->h_length;
+  whsnt.h_addr_list = xx->h_addr_list;
+
+  return &whsnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(WHOSTENT*,OS2gethostbyname,const char*,name)
+{
+  WHOSTENT *yy;
+  struct hostent *xx;
+
+  xx = gethostbyname((char *)name);
+  if(xx == NULL)
+  {
+    SetErrForDatabaseCalls();
+    return (WHOSTENT *)NULL;
+  }
+
+  whsnt.h_name = xx->h_name;
+  whsnt.h_aliases = xx->h_aliases;
+  whsnt.h_addrtype = (short)xx->h_addrtype;
+  whsnt.h_length = (short)xx->h_length;
+  whsnt.h_addr_list = xx->h_addr_list;
+
+  return &whsnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(int,OS2gethostname,char *,name,
+                                 int,   namelen)
+{
+  return gethostname(name,namelen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(WSERVENT*,OS2getservbyport, int,         port,
+                                          const char*, proto)
+{
+  struct servent *xx;
+
+  xx = getservbyport(port,(char *)proto);
+
+  if(xx == NULL)
+  { // this call doesn't generate an error message
+    return (WSERVENT *)NULL;
+  }
+
+  wsvnt.s_name = xx->s_name;
+  wsvnt.s_aliases = xx->s_aliases;
+  wsvnt.s_port = (short)xx->s_port;
+  wsvnt.s_proto = xx->s_proto;
+
+  return &wsvnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(WSERVENT*,OS2getservbyname,const char*,name,
+                                         const char*,proto)
+{
+  WSERVENT *yy;
+  struct servent *xx;
+
+  xx = getservbyname((char *)name,(char *)proto);
+
+  if(xx == NULL)
+  { // this call doesn't generate an error message
+    return (WSERVENT *)NULL;
+  }
+
+  wsvnt.s_name = xx->s_name;
+  wsvnt.s_aliases = xx->s_aliases;
+  wsvnt.s_port = (short)xx->s_port;
+  wsvnt.s_proto = xx->s_proto;
+
+  return &wsvnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(WPROTOENT*,OS2getprotobynumber,int,proto)
+{
+  struct protoent *xx;
+
+  xx = getprotobynumber(proto);
+
+  if(xx == NULL)
+  {
+     // this call doesn't generate an error message
+    return (WPROTOENT *)NULL;
+  }
+
+  wptnt.p_name = xx->p_name;
+  wptnt.p_aliases = xx->p_aliases;
+  wptnt.p_proto = (short)xx->p_proto;
+
+  return &wptnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(WPROTOENT*,OS2getprotobyname,const char*,name)
+{
+  struct protoent *xx;
+
+  xx = getprotobyname((char *)name);
+
+  if(xx == NULL)
+  { // this call doesn't generate an error message
+    return (WPROTOENT *)NULL;
+  }
+
+  wptnt.p_name = xx->p_name;
+  wptnt.p_aliases = xx->p_aliases;
+  wptnt.p_proto = (short)xx->p_proto;
+
+  return &wptnt;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION2(int,OS2WSAStartup,USHORT,   wVersionRequired,
+                                LPWSADATA,lpWsaData)
+{
+  APIRET rc;
+  int ii;
+
   /* Make sure that the version requested is >= 1.1.   */
   /* The low byte is the major version and the high    */
   /* byte is the minor version.                        */
-  
+
   if ( LOBYTE( wVersionRequired ) < 1 ||
        ( LOBYTE( wVersionRequired ) == 1 &&
@@ -750,8 +1310,8 @@
       return WSAVERNOTSUPPORTED;
   }
-  
+
   /* Since we only support 1.1, set both wVersion and  */
   /* wHighVersion to 1.1.                              */
-  
+
   lpWsaData->wVersion = MAKEWORD( 1, 1 );
   lpWsaData->wHighVersion = MAKEWORD( 1, 1 );
@@ -763,5 +1323,6 @@
   LocalErrorNumber = 0;
 
-  if(sock_init() == 0) {
+  if(sock_init() == 0)
+  {
 #ifdef DEBUG
     WriteLog("WSOCK32: WSAStartup sock_init returned 0\n");
@@ -769,98 +1330,154 @@
       return 0;
   }
-  else ii = sock_errno();
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAStartup exiting: %d\n",ii);
-#endif
-return ii;
-}
-
-
-
-
-
-
-int WIN32API OS2WSACleanup(void)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSACleanup\n");
-#endif
-
-    CheckThreads((AsyncStatus *)NULL);
-    
-    return 0;
-}
-
-void WIN32API OS2WSASetLastError(int iError)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSASetLastError(%d)\n",iError);
-#endif
-
-    LocalErrorNumber = iError;
-    
-    return; 
-}
-
-int WIN32API OS2WSAGetLastError(void)
-{
-int ii;
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAGetLastError\n");
-#endif
-
-    if(LocalErrorNumber == 0) {
-        ii = sock_errno(); // WSAGetLastError();
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAGetLastError: %d\n",ii);
-#endif
-	return ii;
-    }
-    else {
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAGetLastError: %d\n",LocalErrorNumber);
-#endif
-	return LocalErrorNumber;
-    }
-}
-
-BOOL WIN32API OS2WSAIsBlocking(void)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAIsBlocking unimplemented\n");
-#endif
-
-    return -5000; //WSAIsBlocking();
-}
-
-int WIN32API OS2WSAUnhookBlockingHook(void)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAUnhookBlockingHook unimplemented\n");
-#endif
-
-    return -5000; //WSAUnhookBlockingHook();
-}
-
-FARPROC WIN32API OS2WSASetBlockingHook(FARPROC lpBlockFunc)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSASetBlockingHook Unimplemented\n");
-#endif
-
-    return (FARPROC)NULL;
-}
-
-int WIN32API OS2WSACancelBlockingCall(void)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSACancelBlockingCall unimplemented\n");
-#endif
-
-    return -5000; //WSACancelBlockingCall();
-}
-
-
-
+  else
+    ii = sock_errno();
+
+  return ii;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION0(int,OS2WSACleanup)
+{
+  CheckThreads((AsyncStatus *)NULL);
+
+  return 0;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINPROCEDURE1(OS2WSASetLastError,int,iError)
+{
+  LocalErrorNumber = iError;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION0(int,OS2WSAGetLastError)
+{
+  int ii;
+
+  if(LocalErrorNumber == 0)
+  {
+    ii = sock_errno(); // WSAGetLastError();
+    return ii;
+  }
+  else
+  {
+    return LocalErrorNumber;
+  }
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION0(BOOL,OS2WSAIsBlocking)
+{
+  dprintf(("WSOCK32: WSAIsBlocking unimplemented\n"));
+
+  return -5000; //WSAIsBlocking();
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION0(int,OS2WSAUnhookBlockingHook)
+{
+  dprintf(("WSOCK32: WSAUnhookBlockingHook unimplemented\n"));
+
+  return -5000; //WSAUnhookBlockingHook();
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(PROC,OS2WSASetBlockingHook,PROC,lpBlockFund)
+{
+  dprintf(("WSOCK32: WSASetBlockingHook Unimplemented\n"));
+  return (PROC)NULL;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION0(int,OS2WSACancelBlockingCall)
+{
+  dprintf(("WSOCK32: WSACancelBlockingCall unimplemented\n"));
+
+  return -5000; //WSACancelBlockingCall();
+}
 
 
@@ -869,429 +1486,334 @@
 // notify the sender.
 
-
-LHANDLE WIN32API OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
-                                        const char * name,
-                                        const char * proto,
-                                        char * buf, int buflen)
-{
-WSAStruct *wsa;
-PFNTHREAD   pfnAsyncThread = &WSAFunct; /* Address of thread program   */
-ULONG       ulThreadParm = 100;          /* Parameter to thread routine     */
-APIRET      rc           = NO_ERROR;     /* Return code */
-TID         tid;
-
-
-OS2WSASetLastError(WSAEWOULDBLOCK);
-return 0;
-
-#ifdef DEBUG
-WriteLog("WSOCK32: WSAAsyncGetServByName.  name: %s, proto: %s \n",name,proto);
-#endif
-
-    wsa = (WSAStruct *)malloc(sizeof(WSAStruct));
-    if(wsa == NULL) {
-        OS2WSASetLastError(WSAEWOULDBLOCK);
-        return 0;
-    }
-
-    wsa->CallingWhat = GETSERVBYNAME;
-    wsa->hw = hWnd;
-    wsa->msg = wMsg;
-    wsa->carg1 = strdup(name);
-    wsa->carg2 = strdup(proto);
-    wsa->buf = buf;
-    wsa->buflen = buflen;
-
-    ulThreadParm = (ULONG)wsa;
-    
-    rc = DosCreateThread(&tid,           /* Thread ID (returned by function)  */
-                         pfnAsyncThread, /* Address of thread program         */
-                         ulThreadParm,   /* Parameter passed to ThreadProc    */
-                         CREATE_READY |  /* Thread is ready when created      */
-                         STACK_SPARSE,   /* Do not pre-commit stack pages     */
-                         8192L);         /* Stack size, rounded to page bdy   */
-    if (rc != NO_ERROR) {
-#ifdef DEBUG
-        WriteLog("WSOCK32: DosCreateThread error in WSAAsyncGetServByName: return code = %u\n", rc);
-#endif
-        OS2WSASetLastError(rc);
-        free(wsa);
-        return 0;
-    }
-
-#ifdef DEBUG
-    WriteLog("WSOCK32 THREAD: DosCreateThread's tid: %lu, ThreadParm = %p\n",(unsigned long)tid,ulThreadParm);
-    WriteLog("WSOCK32 THREAD: hwnd: %p\n",wsa->hw);
-#endif
-
-    return (LHANDLE)tid; //WSAAsyncGetServByName(hWnd,wMsg,name,proto,buf,buflen);
-}
-
-LHANDLE WIN32API OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
-                                        const char * proto, char * buf,
-                                        int buflen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAAsyncGetServByPort unimplemented\n");
-#endif
-
-    return -5000; //WSAAsyncGetServByPort(hWnd,wMsg,port,proto,buf,buflen);
-}
-
-LHANDLE WIN32API OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
-                                         const char * name, char * buf,
-                                         int buflen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAAsyncGetProtoByName unimplemented\n");
-#endif
-
-    return -5000; //WSAAsyncGetProtoByName(hWnd,wMsg,name,buf,buflen);
-}
-
-LHANDLE WIN32API OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
-                                           int number, char * buf,
-                                           int buflen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAAsyncGetProtoByNumber unimplemented\n");
-#endif
-
-    return -5000; //WSAAsyncGetProtoByNumber(hWnd,wMsg,number,buf,buflen);
-}
-
-LHANDLE WIN32API OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
-                                        const char * name, char * buf,
-                                        int buflen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAAsyncGetHostByName unimplemented\n");
-#endif
-
-    return -5000; //WSAAsyncGetHostByName(hWnd,wMsg,name,buf,buflen);
-}
-
-LHANDLE WIN32API OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
-                                        const char * addr, int len, int type,
-                                        char * buf, int buflen)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAAsyncGetHostByAddr unimplemented\n");
-#endif
-
-
-
-
-    
-    return -5000; //WSAAsyncGetHostByAddr(hWnd,wMsg,addr,len,type,buf,buflen);
-}
-
-
-
-
-
-
-
-int WIN32API OS2WSACancelAsyncRequest(LHANDLE hAsyncTaskHandle)
-{
-TID tid;
-APIRET rc;
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSACancelAsyncRequest unimplemented\n");
-#endif
-
-    rc = 0;
-    
-    tid = (LHANDLE)hAsyncTaskHandle;
-
-    if(tid == 0) rc = WSAEINVAL;
-
-    if(!rc) rc = DosKillThread(tid);
-
-    switch(rc) {
-        case 0: // SUCCESS!!
-            return 0;
-        case 170:
-            rc = WSAEINPROGRESS;
-            break;
-        case 309:
-            rc = WSAEINVAL;
-            break;
-        default:
-            rc = -5000;
-            break;
-    } // end switch
-
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION6(LHANDLE,OS2WSAAsyncGetServByName,HWND,        hWnd,
+                                               u_int,       wMsg,
+                                               const char*, name,
+                                               const char*, proto,
+                                               char*,       buf,
+                                               int,         buflen)
+{
+  WSAStruct *wsa;
+  PFNTHREAD   pfnAsyncThread = &WSAFunct; /* Address of thread program   */
+  ULONG       ulThreadParm = 100;          /* Parameter to thread routine     */
+  APIRET      rc           = NO_ERROR;     /* Return code */
+  TID         tid;
+
+
+  OS2WSASetLastError(WSAEWOULDBLOCK);
+  return 0;
+
+  dprintf(("WSOCK32: WSAAsyncGetServByName.  name: %s, proto: %s \n",
+           name,
+           proto));
+
+  wsa = (WSAStruct *)malloc(sizeof(WSAStruct));
+  if(wsa == NULL)
+  {
+    OS2WSASetLastError(WSAEWOULDBLOCK);
+    return 0;
+  }
+
+  wsa->CallingWhat = GETSERVBYNAME;
+  wsa->hw = hWnd;
+  wsa->msg = wMsg;
+  wsa->carg1 = strdup(name);
+  wsa->carg2 = strdup(proto);
+  wsa->buf = buf;
+  wsa->buflen = buflen;
+
+  ulThreadParm = (ULONG)wsa;
+
+  rc = DosCreateThread(&tid,           /* Thread ID (returned by function)  */
+                       pfnAsyncThread, /* Address of thread program         */
+                       ulThreadParm,   /* Parameter passed to ThreadProc    */
+                       CREATE_READY |  /* Thread is ready when created      */
+                       STACK_SPARSE,   /* Do not pre-commit stack pages     */
+                       8192L);         /* Stack size, rounded to page bdy   */
+  if (rc != NO_ERROR)
+  {
+    dprintf(("WSOCK32: DosCreateThread error in WSAAsyncGetServByName: return code = %u\n",
+            rc));
     OS2WSASetLastError(rc);
-    return SOCKET_ERROR; // ERROR!
-}
-
-
-
-
-
-int WIN32API OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
-                            long lEvent)
-{
-PFNTHREAD   pfnAsyncThread = &AsyncLoop; /* Address of thread program   */
-ULONG       ulThreadParm = 100;          /* Parameter to thread routine     */
-APIRET      rc           = NO_ERROR;     /* Return code                     */
-unsigned long ii;
-AsyncStatus *as;
-#ifdef DEBUG
-char buf[150];
-sprintf(buf,"WSOCK32: WSAAsyncSelect\n         Message: %x\n         Event: %ld\n         hwindow: %x\n",
-        wMsg,lEvent,(HWND)hWnd);
-    WriteLog(buf);
-#endif
-
-    as = FindASY(s);
-
-    if(as == NULL) return 0;
-    
-    CheckThreads(as);
-
-    as->hwnd = hWnd;
-    as->msg = wMsg;
-    as->event = lEvent;
-
-    ulThreadParm = (ULONG)as;
-    
-    rc = DosCreateThread(&(as->threadID),  /* Thread ID (returned by function)  */
-                         pfnAsyncThread, /* Address of thread program         */
-                         ulThreadParm,   /* Parameter passed to ThreadProc    */
-                         CREATE_READY |  /* Thread is ready when created      */
-                         STACK_SPARSE,   /* Do not pre-commit stack pages     */
-                         8192L);         /* Stack size, rounded to page bdy   */
-    if (rc != NO_ERROR) {
-#ifdef DEBUG
-        WriteLog("WSOCK32: DosCreateThread error: return code = %u\n", rc);
-#endif
-        OS2WSASetLastError(rc);
-        return 0;
-    }
-
-    return 1; //WSAAsyncSelect(s,hWnd,wMsg,lEvent);
-}
-
-
-
-void _System AsyncLoop(ULONG ASP)
-{
-int socks[1],r,w,e,rc,ii;
-AsyncStatus *as;
-
-    as = (AsyncStatus *)ASP;
-
-    r = w = e = 0;
-    if(as->event & FD_READ) r = 1;
-    if(as->event & FD_WRITE) w = 1;
-    if(as->event & FD_OOB) e = 1;
-
-    socks[0] = (int)as->socket;
-
-    if((r+w+e) == 0) {
-#ifdef DEBUG
-        WriteLog("WSOCK32: Turning off async\n");
-#endif
-        ii = 0;
-        rc = ioctl(socks[0],FIONBIO,(char *)&ii,sizeof(ii));
-        as->threadID = 0;
-        as->hwnd = 0;
-        as->msg = 0;
-        as->event = 0;
-        as->status = BLOCKING;
-        return;
-    } // end if
-    else
-    {
-#ifdef DEBUG
-        WriteLog("WSOCK32: Setting up non-blocking sockets\n");
-#endif
-        ii = 1;
-        rc = ioctl(socks[0],FIONBIO,(char *)&ii,sizeof(ii));
-        if(rc != 0) {
-#ifdef DEBUG
-	    WriteLog("WSOCK32: ioctl failed trying to non-block.\n");
-#endif
-	    return;
-        } 
-        as->status = NONBLOCKING;
-    } // end else
-
-    do {
-        rc = select(socks[0],(fd_set*)&r,0,0,0); // ioctl may be better for this.
-        if(rc > 0) {
-            rc = ioctl(socks[0],FIONREAD,(char *)&ii,sizeof(ii));
-            if(rc == 0 && ii > 0) {
-            /* data is ready */
-                NotifyApp(FD_READ,as);
-//#ifdef DEBUG
-//                WriteLog("WSOCK32: Data Waiting\n");
-//#endif
-            }
-        }
-        if(rc < 0) {
-            rc = sock_errno();
-            /* something ain't right */
-            if(rc == 10038) { // Connection closed
-                NotifyApp(FD_CLOSE,as);
-                DosSleep(500);
-                return;
-            }
-#ifdef DEBUG
-            WriteLog("WSOCK32: Select error: %d\n",rc);
-#endif
-        } // end if
-        DosSleep(50);
-    } while(1);
-
-return;
-}
-
-
-
-void CheckThreads(AsyncStatus *as)
-{
-AsyncStatus *asy;
-
-    if(as != NULL)
-        if(as->threadID != 0) DosKillThread(as->threadID);
-
-    for(asy = TopASY; asy; asy = asy->Next)
-        if(asy->threadID != 0) DosKillThread(asy->threadID);
-    
-return;
-}
-
-
-
-void NotifyApp(int xx,AsyncStatus *as)
-{
-    BOOL    fResult;        /* message-posted indicator             */
-    unsigned long ii;
-
-
-//#ifdef DEBUG
-//    WriteLog("WSOCK32: Notifying the caller.  rc = %d\n",xx);
-//#endif
-
-    if(as->MsgStat == 0) {
-        fResult = Notify(as,xx);
-#ifdef DEBUG
-    WriteLog("WSOCK32: Notify returns: %d\n",fResult);
-#endif
-    } // end if
-
-    if(as->MsgStat == 2) as->MsgStat = 0;
-    else as->MsgStat = 1;
-
-return;
-}
-
-
-
-void _System WSAFunct(ULONG xx)
-{
-WSAStruct *wsa;
-WSERVENT *ooo;
-char *yy;
-int ii;
-size_t ss;
-UINT wp;
-LONG lp;
-int id = *_threadid;
-
-    wsa = (WSAStruct *)xx;
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSAFunct: xx = %p, hwnd = %p\n",xx,wsa->hw);
-    WriteLog("WSOCK32: WSAFunct info carg1 = %s, carg2 = %s\n",wsa->carg1,wsa->carg2);
-    WriteLog("WSOCK32: WSAFunct info buf = %p, %d\n",wsa->buf,wsa->buflen);
-#endif
-
-    switch (wsa->CallingWhat) {
-        case GETSERVBYNAME:
-            yy = (char *)OS2getservbyname(wsa->carg1,wsa->carg2);
-            ss = sizeof(WSERVENT);
-            break;
-        case GETSERVBYPORT:
-            yy = (char *)OS2getservbyport(wsa->iarg1,wsa->carg1);
-            break;
-        case GETPROTOBYNUMBER:
-            yy = (char *)OS2getprotobynumber(wsa->iarg1);
-            break;
-        case GETPROTOBYNAME:
-            yy = (char *)OS2getprotobyname(wsa->carg1);
-            break;
-        case GETHOSTBYNAME:
-            yy = (char *)OS2gethostbyname(wsa->carg1);
-            break;
-        case GETHOSTBYADDR:
-            yy = (char *)OS2gethostbyaddr(wsa->carg1,wsa->iarg1,wsa->iarg2);
-            break;
-        default:
-            yy = (char *)NULL;
-            OS2WSASetLastError(-5000);
-            break;
-    } // end switch
-
-#ifdef DEBUG
-    WriteLog("WSOCK32: THREAD id = %lu\n",(unsigned long)id);
-    if(yy) {
-        ooo = (WSERVENT *)yy;
-        WriteLog("WSOCK32: WSAFunct service name = %s\n",ooo->s_name);
-        WriteLog("WSOCK32: WSAFunct service port = %d\n",(int)ooo->s_port);
-    }
-#endif
-
-    wp = id;
-
-    if(yy == (char *)NULL) {
-#ifdef DEBUG
-        WriteLog("WSOCK32: WSAFunct error\n");
-        WriteLog("WSOCK32: WSAFunct error carg1 = %s, carg2 = %s\n",wsa->carg1,wsa->carg2);
-#endif
-        ii = OS2WSAGetLastError();
-        lp = OS2WSAMAKEASYNCREPLY(0,ii);
-    } // end if
-
-    else {
-        if(wsa->buflen < ss) ii = WSAENOBUFS;
-        else ii = 0;
-        lp = OS2WSAMAKEASYNCREPLY(ss,ii);
-        if(ii == 0) memmove(wsa->buf,yy,ss);
-    }
-
-#ifdef DEBUG
-#endif
-
-    
-    do {
-        if(WinQueryAnchorBlock(wsa->hw))
-            ii = NotifyWSA(wsa->hw,wsa->msg,wp,lp);
-    } while(ii != TRUE);
-
     free(wsa);
-
-return;
-}
-
-
-
-    
-
-int WIN32API OS2WSARecvEx (SOCKET s, char FAR * buf, int len, int FAR *flags)
-{
-#ifdef DEBUG
-    WriteLog("WSOCK32: WSARecvEx not implemented.\n");
-#endif
+    return 0;
+  }
+
+  dprintf(("WSOCK32 THREAD: DosCreateThread's tid: %lu, ThreadParm = %p\n",
+           (unsigned long)tid,
+           ulThreadParm));
+  dprintf(("WSOCK32 THREAD: hwnd: %p\n",wsa->hw));
+
+  return (LHANDLE)tid; //WSAAsyncGetServByName(hWnd,wMsg,name,proto,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION6(LHANDLE,OS2WSAAsyncGetServByPort,HWND,        hWnd,
+                                               u_int,       wMsg,
+                                               int,         port,
+                                               const char*, proto,
+                                               char*,       buf,
+                                               int,         buflen)
+{
+  dprintf(("WSOCK32: WSAAsyncGetServByPort unimplemented\n"));
+
+  return -5000; //WSAAsyncGetServByPort(hWnd,wMsg,port,proto,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetProtoByName,HWND,        hWnd,
+                                                u_int,       wMsg,
+                                                const char*, name,
+                                                char *,      buf,
+                                                int,         buflen)
+{
+  dprintf(("WSOCK32: WSAAsyncGetProtoByName unimplemented\n"));
+  return -5000; //WSAAsyncGetProtoByName(hWnd,wMsg,name,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetProtoByNumber,HWND,   hWnd,
+                                                  u_int,  wMsg,
+                                                  int,    number,
+                                                  char *, buf,
+                                                  int,    buflen)
+{
+  dprintf(("WSOCK32: WSAAsyncGetProtoByNumber unimplemented\n"));
+  return -5000; //WSAAsyncGetProtoByNumber(hWnd,wMsg,number,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetHostByName,HWND,         hWnd,
+                                               u_int,        wMsg,
+                                               const char *, name,
+                                               char *,       buf,
+                                               int,          buflen)
+{
+  dprintf(("WSOCK32: WSAAsyncGetHostByName unimplemented\n"));
+  return -5000; //WSAAsyncGetHostByName(hWnd,wMsg,name,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION7(LHANDLE, OS2WSAAsyncGetHostByAddr, HWND,        hWnd,
+                                                 u_int,       wMsg,
+                                                 const char*, addr,
+                                                 int,         len,
+                                                 int,         type,
+                                                 char*,       buf,
+                                                 int,         buflen)
+{
+  dprintf(("WSOCK32: WSAAsyncGetHostByAddr unimplemented\n"));
+
+  return -5000; //WSAAsyncGetHostByAddr(hWnd,wMsg,addr,len,type,buf,buflen);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION1(int, OS2WSACancelAsyncRequest,LHANDLE,hAsyncTaskHandle)
+{
+  TID    tid;
+  APIRET rc;
+
+  dprintf(("WSOCK32: WSACancelAsyncRequest unimplemented\n"));
+
+  tid = (LHANDLE)hAsyncTaskHandle;
+  if(tid == 0)
+    rc = WSAEINVAL;
+  else
+    rc = DosKillThread(tid);
+
+  switch(rc)
+  {
+    case 0: // SUCCESS!!
+      return 0;
+    case 170:
+      rc = WSAEINPROGRESS;
+      break;
+    case 309:
+      rc = WSAEINVAL;
+      break;
+    default:
+      rc = -5000;
+      break;
+  } // end switch
+
+  OS2WSASetLastError(rc);
+  return SOCKET_ERROR; // ERROR!
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION4(int, OS2WSAAsyncSelect, SOCKET, s,
+                                      HWND,   hWnd,
+                                      u_int,  wMsg,
+                                      long,   lEvent)
+{
+  PFNTHREAD   pfnAsyncThread = &AsyncLoop; /* Address of thread program   */
+  ULONG       ulThreadParm = 100;          /* Parameter to thread routine     */
+  APIRET      rc           = NO_ERROR;     /* Return code                     */
+  unsigned long ii;
+  AsyncStatus *as;
+
+  as = FindASY(s);
+  if(as == NULL)
+    return 0;
+
+  CheckThreads(as);
+
+  as->hwnd = hWnd;
+  as->msg = wMsg;
+  as->event = lEvent;
+
+  ulThreadParm = (ULONG)as;
+
+  rc = DosCreateThread(&(as->threadID),  /* Thread ID (returned by function)  */
+                       pfnAsyncThread, /* Address of thread program         */
+                       ulThreadParm,   /* Parameter passed to ThreadProc    */
+                       CREATE_READY |  /* Thread is ready when created      */
+                       STACK_SPARSE,   /* Do not pre-commit stack pages     */
+                       8192L);         /* Stack size, rounded to page bdy   */
+  if (rc != NO_ERROR)
+  {
+    dprintf(("WSOCK32: DosCreateThread error: return code = %u\n",
+             rc));
+    OS2WSASetLastError(rc);
+    return 0;
+  }
+
+  return 1; //WSAAsyncSelect(s,hWnd,wMsg,lEvent);
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINFUNCTION4(int, OS2WSARecvEx, SOCKET,    s,
+                                 char FAR*, buf,
+                                 int,       len,
+                                 int FAR *,flags)
+{
+  dprintf(("WSOCK32: WSARecvEx not implemented.\n"));
 
 //    return WSARecvEx(s,buf,len,flags);
-    return 0;
-}
-
-void WIN32API OS2s_perror(char *pszMessage,
-                          void *pUnknown)
+  return 0;
+}
+
+
+/*****************************************************************************
+ * Name      :
+ * Purpose   :
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
+ *****************************************************************************/
+
+ODINPROCEDURE2(OS2s_perror, char*, pszMessage,
+                            void*, pUnknown)
 {
   perror(pszMessage);
@@ -1299,31 +1821,2 @@
 
 
-//typedef struct _TRANSMIT_FILE_BUFFERS {
-//    PVOID Head;
-//    DWORD HeadLength;
-//    PVOID Tail;
-//    DWORD TailLength;
-//} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
-//
-//BOOL WIN32API OS2TransmitFile (
-//    IN SOCKET hSocket,
-//    IN HANDLE hFile,
-//    IN DWORD nNumberOfBytesToWrite,
-//    IN DWORD nNumberOfBytesPerSend,
-//    IN LPOVERLAPPED lpOverlapped,
-//    IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
-//    IN DWORD dwReserved)
-//{
-//    return FALSE;
-//}
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/src/wsock32/wsock32.h
===================================================================
--- trunk/src/wsock32/wsock32.h	(revision 517)
+++ trunk/src/wsock32/wsock32.h	(revision 518)
@@ -1,3 +1,3 @@
-/* $Id: wsock32.h,v 1.3 1999-06-10 16:11:08 phaller Exp $ */
+/* $Id: wsock32.h,v 1.4 1999-08-16 20:18:40 phaller Exp $ */
 
 /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
@@ -16,29 +16,27 @@
 #define _WINSOCKAPI_
 
-#define FAR
-
-#ifndef IN
-#define IN
-#endif
-
 
 #ifdef MAKELONG
-#undef MAKELONG
-#endif
+#  undef MAKELONG
+#endif
+
 #ifdef MAKEWORD
-#undef MAKEWORD
+#  undef MAKEWORD
 #endif
 
 #ifdef LOBYTE
-#undef LOBYTE
-#endif
+#  undef LOBYTE
+#endif
+
 #ifdef LOWORD
-#undef LOWORD
-#endif
+#  undef LOWORD
+#endif
+
 #ifdef HIBYTE
-#undef HIBYTE
-#endif
+#  undef HIBYTE
+#endif
+
 #ifdef HIWORD
-#undef HIWORD
+#  undef HIWORD
 #endif
 
@@ -61,7 +59,7 @@
 typedef unsigned int    u_int;
 typedef unsigned long   u_long;
-//typedef int (FAR WINAPI *FARPROC)();
+  typedef int ( WIN32API *PROC)();
 #else
-//typedef int (* FAR WINAPI FARPROC)();
+  typedef int (*  WIN32API PROC)();
 #endif
 
@@ -113,9 +111,11 @@
 } Wfd_set;
 
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern int PASCAL FAR __WSAFDIsSet(SOCKET, Wfd_set FAR *);
+extern int PASCAL  __WSAFDIsSet(SOCKET, Wfd_set  *);
 
 #ifdef __cplusplus
@@ -123,15 +123,15 @@
 #endif
 
-
+/*
 #define FD_CLR(fd, set) do { \
     u_int __i; \
-    for (__i = 0; __i < ((Wfd_set FAR *)(set))->fd_count ; __i++) { \
-        if (((Wfd_set FAR *)(set))->fd_array[__i] == fd) { \
-            while (__i < ((Wfd_set FAR *)(set))->fd_count-1) { \
-                ((Wfd_set FAR *)(set))->fd_array[__i] = \
-                    ((Wfd_set FAR *)(set))->fd_array[__i+1]; \
+    for (__i = 0; __i < ((Wfd_set  *)(set))->fd_count ; __i++) { \
+        if (((Wfd_set  *)(set))->fd_array[__i] == fd) { \
+            while (__i < ((Wfd_set  *)(set))->fd_count-1) { \
+                ((Wfd_set  *)(set))->fd_array[__i] = \
+                    ((Wfd_set  *)(set))->fd_array[__i+1]; \
                 __i++; \
             } \
-            ((Wfd_set FAR *)(set))->fd_count--; \
+            ((Wfd_set  *)(set))->fd_count--; \
             break; \
         } \
@@ -140,11 +140,12 @@
 
 #define FD_SET(fd, set) do { \
-    if (((Wfd_set FAR *)(set))->fd_count < FD_SETSIZE) \
-        ((Wfd_set FAR *)(set))->fd_array[((Wfd_set FAR *)(set))->fd_count++]=(fd);\
+    if (((Wfd_set  *)(set))->fd_count < FD_SETSIZE) \
+        ((Wfd_set  *)(set))->fd_array[((Wfd_set  *)(set))->fd_count++]=(fd);\
 } while(0)
 
-#define FD_ZERO(set) (((Wfd_set FAR *)(set))->fd_count=0)
-
-#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (Wfd_set FAR *)(set))
+#define FD_ZERO(set) (((Wfd_set  *)(set))->fd_count=0)
+
+#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (Wfd_set  *)(set))
+*/
 
 /*
@@ -208,9 +209,9 @@
 
 struct  Whostent {
-        char    FAR * h_name;           /* official name of host */
-        char    FAR * FAR * h_aliases;  /* alias list */
+        char     * h_name;           /* official name of host */
+        char     *  * h_aliases;  /* alias list */
         short   h_addrtype;             /* host address type */
         short   h_length;               /* length of address */
-        char    FAR * FAR * h_addr_list; /* list of addresses */
+        char     *  * h_addr_list; /* list of addresses */
 #define h_addr  h_addr_list[0]          /* address, for backward compat */
 };
@@ -221,6 +222,6 @@
  */
 struct  Wnetent {
-        char    FAR * n_name;           /* official name of net */
-        char    FAR * FAR * n_aliases;  /* alias list */
+        char     * n_name;           /* official name of net */
+        char     *  * n_aliases;  /* alias list */
         short   n_addrtype;             /* net address type */
         u_long  n_net;                  /* network # */
@@ -228,13 +229,13 @@
 
 struct  Wservent {
-        char    FAR * s_name;           /* official service name */
-        char    FAR * FAR * s_aliases;  /* alias list */
+        char     * s_name;           /* official service name */
+        char     *  * s_aliases;  /* alias list */
         short   s_port;                 /* port # */
-        char    FAR * s_proto;          /* protocol to use */
+        char     * s_proto;          /* protocol to use */
 };
 
 struct  Wprotoent {
-        char    FAR * p_name;           /* official protocol name */
-        char    FAR * FAR * p_aliases;  /* alias list */
+        char     * p_name;           /* official protocol name */
+        char     *  * p_aliases;  /* alias list */
         short   p_proto;                /* protocol # */
 };
@@ -384,8 +385,8 @@
         unsigned short          iMaxSockets;
         unsigned short          iMaxUdpDg;
-        char FAR *              lpVendorInfo;
+        char  *              lpVendorInfo;
 } WSADATA;
 
-typedef WSADATA FAR *LPWSADATA;
+typedef WSADATA  *LPWSADATA;
 
 /*
@@ -666,125 +667,57 @@
 #endif
 
-SOCKET WIN32API FAR OS2accept (SOCKET s, struct sockaddr *addr,
-                          int *addrlen);
-
-int WIN32API FAR OS2bind (SOCKET s, const struct sockaddr FAR *addr, int namelen);
-
-int WIN32API FAR OS2closesocket (SOCKET s);
-
-int WIN32API FAR OS2connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
-
-int WIN32API FAR OS2ioctlsocket (SOCKET s, long cmd, u_long FAR *argp);
-
-int WIN32API FAR OS2getpeername (SOCKET s, struct sockaddr FAR *name,
-                            int FAR * namelen);
-
-int WIN32API FAR OS2getsockname (SOCKET s, struct sockaddr FAR *name,
-                            int FAR * namelen);
-
-int WIN32API FAR OS2getsockopt (SOCKET s, int level, int optname,
-                           char FAR * optval, int FAR *optlen);
-
-u_long WIN32API FAR OS2htonl (u_long hostlong);
-
-u_short WIN32API FAR OS2htons (u_short hostshort);
-
-unsigned long WIN32API FAR OS2inet_addr (const char FAR * cp);
-
-char FAR * WIN32API FAR OS2inet_ntoa (struct in_addr in);
-
-int WIN32API FAR OS2listen (SOCKET s, int backlog);
-
-u_long WIN32API FAR OS2ntohl (u_long netlong);
-
-u_short WIN32API FAR OS2ntohs (u_short netshort);
-
-int WIN32API FAR OS2recv (SOCKET s, char FAR * buf, int len, int flags);
-
-int WIN32API FAR OS2recvfrom (SOCKET s, char FAR * buf, int len, int flags,
-                         struct sockaddr FAR *from, int FAR * fromlen);
-
-int WIN32API FAR OS2select (int nfds, Wfd_set FAR *readfds, Wfd_set FAR *writefds,
-                       Wfd_set FAR *exceptfds, const struct Wtimeval FAR *timeout);
-
-int WIN32API FAR OS2send (SOCKET s, const char FAR * buf, int len, int flags);
-
-int WIN32API FAR OS2sendto (SOCKET s, const char FAR * buf, int len, int flags,
-                       const struct sockaddr FAR *to, int tolen);
-
-int WIN32API FAR OS2setsockopt (SOCKET s, int level, int optname,
-                           const char FAR * optval, int optlen);
-
-int WIN32API FAR OS2shutdown (SOCKET s, int how);
-
-SOCKET WIN32API FAR OS2socket (int af, int type, int protocol);
+SOCKET  WIN32API  OS2accept (SOCKET s, struct sockaddr *addr, int *addrlen);
+int     WIN32API  OS2bind (SOCKET s, const struct sockaddr  *addr, int namelen);
+int     WIN32API  OS2closesocket (SOCKET s);
+int     WIN32API  OS2connect (SOCKET s, const struct sockaddr  *name, int namelen);
+int     WIN32API  OS2ioctlsocket (SOCKET s, long cmd, u_long  *argp);
+int     WIN32API  OS2getpeername (SOCKET s, struct sockaddr  *name,  int  * namelen);
+int     WIN32API  OS2getsockname (SOCKET s, struct sockaddr  *name, int  * namelen);
+int     WIN32API  OS2getsockopt (SOCKET s, int level, int optname, char  * optval, int  *optlen);
+u_long  WIN32API  OS2htonl (u_long hostlong);
+u_short WIN32API  OS2htons (u_short hostshort);
+u_long  WIN32API  OS2inet_addr (const char  * cp);
+char  * WIN32API  OS2inet_ntoa (struct in_addr in);
+int     WIN32API  OS2listen (SOCKET s, int backlog);
+u_long  WIN32API  OS2ntohl (u_long netlong);
+u_short WIN32API  OS2ntohs (u_short netshort);
+int     WIN32API  OS2recv (SOCKET s, char  * buf, int len, int flags);
+int     WIN32API  OS2recvfrom (SOCKET s, char  * buf, int len, int flags, struct sockaddr  *from, int  * fromlen);
+int     WIN32API  OS2select (int nfds, Wfd_set  *readfds, Wfd_set  *writefds, Wfd_set  *exceptfds, const struct Wtimeval  *timeout);
+int     WIN32API  OS2send (SOCKET s, const char  * buf, int len, int flags);
+int     WIN32API  OS2sendto (SOCKET s, const char  * buf, int len, int flags, const struct sockaddr  *to, int tolen);
+int     WIN32API  OS2setsockopt (SOCKET s, int level, int optname, const char  * optval, int optlen);
+int     WIN32API  OS2shutdown (SOCKET s, int how);
+SOCKET  WIN32API  OS2socket (int af, int type, int protocol);
 
 /* Database function prototypes */
-
-struct Whostent FAR * WIN32API FAR OS2gethostbyaddr(const char FAR * addr,
-                                              int len, int type);
-
-struct Whostent FAR * WIN32API FAR OS2gethostbyname(const char FAR * name);
-
-int WIN32API FAR OS2gethostname (char FAR * name, int namelen);
-
-struct Wservent FAR * WIN32API FAR OS2getservbyport(int port, const char FAR * proto);
-
-struct Wservent FAR * WIN32API FAR OS2getservbyname(const char FAR * name,
-                                              const char FAR * proto);
-
-struct Wprotoent FAR * WIN32API FAR OS2getprotobynumber(int proto);
-
-struct Wprotoent FAR * WIN32API FAR OS2getprotobyname(const char FAR * name);
+struct Whostent  *  WIN32API OS2gethostbyaddr(const char  * addr, int len, int type);
+struct Whostent  *  WIN32API OS2gethostbyname(const char  * name);
+int                 WIN32API OS2gethostname (char  * name, int namelen);
+struct Wservent  *  WIN32API OS2getservbyport(int port, const char  * proto);
+struct Wservent  *  WIN32API OS2getservbyname(const char  * name, const char  * proto);
+struct Wprotoent  * WIN32API OS2getprotobynumber(int proto);
+struct Wprotoent  * WIN32API OS2getprotobyname(const char  * name);
 
 /* Microsoft Windows Extension function prototypes */
-
-int WIN32API FAR OS2WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
-
-int WIN32API FAR OS2WSACleanup(void);
-
-void WIN32API FAR OS2WSASetLastError(int iError);
-
-int WIN32API FAR OS2WSAGetLastError(void);
-
-BOOL WIN32API FAR OS2WSAIsBlocking(void);
-
-int WIN32API FAR OS2WSAUnhookBlockingHook(void);
-
-FARPROC WIN32API FAR OS2WSASetBlockingHook(FARPROC lpBlockFunc);
-
-int WIN32API FAR OS2WSACancelBlockingCall(void);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg,
-                                        const char FAR * name,
-                                        const char FAR * proto,
-                                        char FAR * buf, int buflen);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port,
-                                        const char FAR * proto, char FAR * buf,
-                                        int buflen);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg,
-                                         const char FAR * name, char FAR * buf,
-                                         int buflen);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg,
-                                           int number, char FAR * buf,
-                                           int buflen);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
-                                        const char FAR * name, char FAR * buf,
-                                        int buflen);
-
-HANDLE WIN32API FAR OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg,
-                                        const char FAR * addr, int len, int type,
-                                        char FAR * buf, int buflen);
-
-int WIN32API FAR OS2WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
-
-int WIN32API FAR OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg,
-                               long lEvent);
-
-int WIN32API FAR OS2WSARecvEx (SOCKET s, char FAR * buf, int len, int FAR *flags);
+int    WIN32API  OS2WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
+int    WIN32API  OS2WSACleanup(void);
+void   WIN32API  OS2WSASetLastError(int iError);
+int    WIN32API  OS2WSAGetLastError(void);
+BOOL   WIN32API  OS2WSAIsBlocking(void);
+int    WIN32API  OS2WSAUnhookBlockingHook(void);
+PROC   WIN32API  OS2WSASetBlockingHook(PROC lpBlockFunc);
+int    WIN32API  OS2WSACancelBlockingCall(void);
+HANDLE WIN32API  OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char  * name, const char  * proto, char  * buf, int buflen);
+HANDLE WIN32API  OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, const char  * proto, char  * buf, int buflen);
+HANDLE WIN32API  OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char  * name, char  * buf, int buflen);
+HANDLE WIN32API  OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, int number, char  * buf, int buflen);
+HANDLE WIN32API  OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char  * name, char  * buf, int buflen);
+HANDLE WIN32API  OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char  * addr, int len, int type, char  * buf, int buflen);
+int    WIN32API  OS2WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
+int    WIN32API  OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
+int    WIN32API  OS2WSARecvEx (SOCKET s, char  * buf, int len, int  *flags);
+
+
 
 typedef struct _TRANSMIT_FILE_BUFFERS {
@@ -804,16 +737,11 @@
 
 
-
-BOOL
-WIN32API FAR
-OS2TransmitFile (
-    IN SOCKET hSocket,
-    IN HANDLE hFile,
-    IN DWORD nNumberOfBytesToWrite,
-    IN DWORD nNumberOfBytesPerSend,
-    IN LPOVERLAPPED lpOverlapped,
-    IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
-    IN DWORD dwReserved
-    );
+BOOL WIN32API OS2TransmitFile (SOCKET                  hSocket,
+                               HANDLE                  hFile,
+                               DWORD                   nNumberOfBytesToWrite,
+                               DWORD                   nNumberOfBytesPerSend,
+                               LPOVERLAPPED            lpOverlapped,
+                               LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
+                               DWORD                   dwReserved);
 
 #ifdef __cplusplus
@@ -823,37 +751,37 @@
 typedef struct sockaddr SOCKADDR;
 typedef struct sockaddr *PSOCKADDR;
-typedef struct sockaddr FAR *LPSOCKADDR;
+typedef struct sockaddr *LPSOCKADDR;
 
 typedef struct sockaddr_in SOCKADDR_IN;
 typedef struct sockaddr_in *PSOCKADDR_IN;
-typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
+typedef struct sockaddr_in *LPSOCKADDR_IN;
 
 typedef struct linger LINGER;
 typedef struct linger *PLINGER;
-typedef struct linger FAR *LPLINGER;
+typedef struct linger *LPLINGER;
 
 typedef struct in_addr IN_ADDR;
 typedef struct in_addr *PIN_ADDR;
-typedef struct in_addr FAR *LPIN_ADDR;
+typedef struct in_addr *LPIN_ADDR;
 
 typedef struct Wfd_set WFD_SET;
 typedef struct Wfd_set *PWFD_SET;
-typedef struct Wfd_set FAR *LPWFD_SET;
+typedef struct Wfd_set *LPWFD_SET;
 
 typedef struct Whostent WHOSTENT;
 typedef struct Whostent *PWHOSTENT;
-typedef struct Whostent FAR *LPWHOSTENT;
+typedef struct Whostent *LPWHOSTENT;
 
 typedef struct Wservent WSERVENT;
 typedef struct Wservent *PWSERVENT;
-typedef struct Wservent FAR *LPWSERVENT;
+typedef struct Wservent *LPWSERVENT;
 
 typedef struct Wprotoent WPROTOENT;
 typedef struct Wprotoent *PWPROTOENT;
-typedef struct Wprotoent FAR *LPWPROTOENT;
+typedef struct Wprotoent *LPWPROTOENT;
 
 typedef struct Wtimeval WTIMEVAL;
 typedef struct Wtimeval *PWTIMEVAL;
-typedef struct Wtimeval FAR *LPWTIMEVAL;
+typedef struct Wtimeval *LPWTIMEVAL;
 
 /*
