| 1 | /* $Id: wsock32.cpp,v 1.13 1999-11-10 16:39:46 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | *
|
|---|
| 5 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 6 | *
|
|---|
| 7 | * Win32 SOCK32 for OS/2
|
|---|
| 8 | *
|
|---|
| 9 | * 1998/08/25 Vince Vielhaber
|
|---|
| 10 | *
|
|---|
| 11 | * @(#) wsock32.c 1.0.0 1998/08/25 VV initial release
|
|---|
| 12 | * 1.0.1 1999/04/27 VV cleanup and implement select.
|
|---|
| 13 | *
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | /* Remark:
|
|---|
| 17 | * PH 1999/11/10 memory leak as WSOCKTHREADDATA is NOT yet
|
|---|
| 18 | * freed when thread dies!
|
|---|
| 19 | * PH 1999/11/10 asyncSelect() still left to proper implementation
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | /*****************************************************************************
|
|---|
| 24 | * Includes *
|
|---|
| 25 | *****************************************************************************/
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | #define INCL_DOSPROCESS /* Process and thread values */
|
|---|
| 29 | #define INCL_DOSFILEMGR /* for DosRead and DosWrite */
|
|---|
| 30 | #define INCL_DOSQUEUES /* for unnamed pipes */
|
|---|
| 31 | #define INCL_DOSERRORS /* DOS error values */
|
|---|
| 32 | #define INCL_WINMESSAGEMGR /* Window Message Functions */
|
|---|
| 33 | #define INCL_WINMENUS /* Window Menu Functions */
|
|---|
| 34 |
|
|---|
| 35 | /* this is for IBM TCP/IP 5.0 headers as present in the current Warp 4 toolkit */
|
|---|
| 36 | #define TCPV40HDRS 1
|
|---|
| 37 |
|
|---|
| 38 | #define VV_BSD_SELECT /* undefine this if it interferes with other routines */
|
|---|
| 39 |
|
|---|
| 40 | #ifdef VV_BSD_SELECT
|
|---|
| 41 | # define BSD_SELECT
|
|---|
| 42 | #endif
|
|---|
| 43 |
|
|---|
| 44 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 45 | #include <stdio.h>
|
|---|
| 46 | #include <stdlib.h>
|
|---|
| 47 | #include <stddef.h>
|
|---|
| 48 | #include <string.h>
|
|---|
| 49 | #include <ctype.h>
|
|---|
| 50 | #include <types.h>
|
|---|
| 51 | #include <odinwrap.h>
|
|---|
| 52 | #include <netdb.h>
|
|---|
| 53 | #include <sys/socket.h>
|
|---|
| 54 | #include <sys/ioctl.h>
|
|---|
| 55 | #include <netinet/in.h>
|
|---|
| 56 |
|
|---|
| 57 | #ifdef VV_BSD_SELECT
|
|---|
| 58 | # include <sys/select.h>
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | #include <sys/time.h>
|
|---|
| 62 | #include <win32type.h>
|
|---|
| 63 | #include <wprocess.h>
|
|---|
| 64 | #include <heapstring.h>
|
|---|
| 65 |
|
|---|
| 66 | #include "wsock32const.h"
|
|---|
| 67 | #include "wsock32.h"
|
|---|
| 68 | #include "misc.h"
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | ODINDEBUGCHANNEL(WSOCK32-WSOCK32)
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | /*****************************************************************************
|
|---|
| 75 | * Defines *
|
|---|
| 76 | *****************************************************************************/
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | #ifdef FD_CLR
|
|---|
| 80 | #undef FD_CLR
|
|---|
| 81 | #define FD_CLR(x,y) WFD_CLR(x,y)
|
|---|
| 82 | #undef FD_SET
|
|---|
| 83 | #define FD_SET(x,y) WFD_SET(x,y)
|
|---|
| 84 | #undef FD_ZERO
|
|---|
| 85 | #define FD_ZERO(x) WFD_ZERO(x)
|
|---|
| 86 | #undef FD_ISSET
|
|---|
| 87 | #define FD_ISSET(x,y) WFD_SET(x,y)
|
|---|
| 88 | #endif
|
|---|
| 89 |
|
|---|
| 90 | #ifndef ERROR_SUCCESS
|
|---|
| 91 | #define ERROR_SUCCESS 0
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | // forwarder prototypes
|
|---|
| 96 | void _System SetLastError(int iError);
|
|---|
| 97 | int _System GetLastError(void);
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | /*****************************************************************************
|
|---|
| 101 | * Structures *
|
|---|
| 102 | *****************************************************************************/
|
|---|
| 103 |
|
|---|
| 104 | typedef struct sockaddr* PSOCKADDR;
|
|---|
| 105 |
|
|---|
| 106 | //typedef struct _TRANSMIT_FILE_BUFFERS {
|
|---|
| 107 | // PVOID Head;
|
|---|
| 108 | // DWORD HeadLength;
|
|---|
| 109 | // PVOID Tail;
|
|---|
| 110 | // DWORD TailLength;
|
|---|
| 111 | //} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
|
|---|
| 112 | //
|
|---|
| 113 | //BOOL, OS2TransmitFile, //, IN, SOCKET, hSocket, //, IN, HANDLE, hFile, //, IN, DWORD, nNumberOfBytesToWrite, //, IN DWORD nNumberOfBytesPerSend,
|
|---|
| 114 | // IN LPOVERLAPPED lpOverlapped,
|
|---|
| 115 | // IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
|---|
| 116 | // IN DWORD dwReserved)
|
|---|
| 117 | //{
|
|---|
| 118 | // return FALSE;
|
|---|
| 119 | //}
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | /*****************************************************************************
|
|---|
| 123 | * Prototypes *
|
|---|
| 124 | *****************************************************************************/
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | /*****************************************************************************
|
|---|
| 128 | * Local variables *
|
|---|
| 129 | *****************************************************************************/
|
|---|
| 130 |
|
|---|
| 131 | // @@@PH not reentrancy proof
|
|---|
| 132 | //<_sandervl> phs: I already have a rewrite of the error support in wsock. Use the
|
|---|
| 133 | // GetThreadTHDB export in kernel32 and add a DWORD to the thread
|
|---|
| 134 | // structure in include\win\thread.h
|
|---|
| 135 |
|
|---|
| 136 | typedef struct tagWsockThreadData
|
|---|
| 137 | {
|
|---|
| 138 | DWORD dwLastError; // Get/SetLastError
|
|---|
| 139 | WHOSTENT whsnt; // database conversion buffers
|
|---|
| 140 | WSERVENT wsvnt;
|
|---|
| 141 | WPROTOENT wptnt;
|
|---|
| 142 | } WSOCKTHREADDATA, *PWSOCKTHREADDATA;
|
|---|
| 143 |
|
|---|
| 144 | static WSOCKTHREADDATA wstdFallthru; // for emergency only
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 | /*****************************************************************************
|
|---|
| 148 | * Name :
|
|---|
| 149 | * Purpose :
|
|---|
| 150 | * Parameters:
|
|---|
| 151 | * Variables :
|
|---|
| 152 | * Result :
|
|---|
| 153 | * Remark : free memory when thread dies
|
|---|
| 154 | * Status : UNTESTED STUB
|
|---|
| 155 | *
|
|---|
| 156 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 157 | *****************************************************************************/
|
|---|
| 158 |
|
|---|
| 159 | PWSOCKTHREADDATA iQueryWsockThreadData(void)
|
|---|
| 160 | {
|
|---|
| 161 | struct _THDB* pThreadDB = (struct _THDB*)GetThreadTHDB();
|
|---|
| 162 | PWSOCKTHREADDATA pwstd;
|
|---|
| 163 |
|
|---|
| 164 | // check for existing pointer
|
|---|
| 165 | if (pThreadDB != NULL)
|
|---|
| 166 | {
|
|---|
| 167 | if (pThreadDB->pWsockData == NULL)
|
|---|
| 168 | {
|
|---|
| 169 | // allocate on demand + initialize
|
|---|
| 170 | pwstd = (PWSOCKTHREADDATA)HEAP_malloc (sizeof(WSOCKTHREADDATA));
|
|---|
| 171 | pThreadDB->pWsockData = (LPVOID)pwstd;
|
|---|
| 172 | }
|
|---|
| 173 | else
|
|---|
| 174 | // use already allocated memory
|
|---|
| 175 | pwstd = (PWSOCKTHREADDATA)pThreadDB->pWsockData;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | if (pwstd == NULL)
|
|---|
| 179 | pwstd = &wstdFallthru; // no memory and not allocated already
|
|---|
| 180 |
|
|---|
| 181 | return pwstd;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | /*****************************************************************************
|
|---|
| 186 | * Name :
|
|---|
| 187 | * Purpose :
|
|---|
| 188 | * Parameters:
|
|---|
| 189 | * Variables :
|
|---|
| 190 | * Result :
|
|---|
| 191 | * Remark :
|
|---|
| 192 | * Status : UNTESTED STUB
|
|---|
| 193 | *
|
|---|
| 194 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 195 | *****************************************************************************/
|
|---|
| 196 |
|
|---|
| 197 | #define CASEERR2(a) case SOC##a: case a: return WSA##a;
|
|---|
| 198 | #define CASEERR1(a) case SOC##a: return WSA##a;
|
|---|
| 199 |
|
|---|
| 200 | int iTranslateSockErrToWSock(int iError)
|
|---|
| 201 | {
|
|---|
| 202 | switch(iError)
|
|---|
| 203 | {
|
|---|
| 204 | CASEERR2(EINTR)
|
|---|
| 205 | CASEERR2(EBADF)
|
|---|
| 206 | CASEERR2(EACCES)
|
|---|
| 207 | CASEERR2(EINVAL)
|
|---|
| 208 | CASEERR2(EMFILE)
|
|---|
| 209 |
|
|---|
| 210 | CASEERR1(EWOULDBLOCK)
|
|---|
| 211 | CASEERR1(EINPROGRESS)
|
|---|
| 212 | CASEERR1(EALREADY)
|
|---|
| 213 | CASEERR1(ENOTSOCK)
|
|---|
| 214 | // CASEERR1(EDESTADRREQ)
|
|---|
| 215 | CASEERR1(EMSGSIZE)
|
|---|
| 216 | CASEERR1(EPROTOTYPE)
|
|---|
| 217 | CASEERR1(ENOPROTOOPT)
|
|---|
| 218 | CASEERR1(EPROTONOSUPPORT)
|
|---|
| 219 | CASEERR1(ESOCKTNOSUPPORT)
|
|---|
| 220 | CASEERR1(EOPNOTSUPP)
|
|---|
| 221 | CASEERR1(EPFNOSUPPORT)
|
|---|
| 222 | CASEERR1(EAFNOSUPPORT)
|
|---|
| 223 | CASEERR1(EADDRINUSE)
|
|---|
| 224 | CASEERR1(EADDRNOTAVAIL)
|
|---|
| 225 | CASEERR1(ENETDOWN)
|
|---|
| 226 | CASEERR1(ENETUNREACH)
|
|---|
| 227 | CASEERR1(ENETRESET)
|
|---|
| 228 | CASEERR1(ECONNABORTED)
|
|---|
| 229 | CASEERR1(ECONNRESET)
|
|---|
| 230 | CASEERR1(ENOBUFS)
|
|---|
| 231 | CASEERR1(EISCONN)
|
|---|
| 232 | CASEERR1(ENOTCONN)
|
|---|
| 233 | CASEERR1(ESHUTDOWN)
|
|---|
| 234 | CASEERR1(ETOOMANYREFS)
|
|---|
| 235 | CASEERR1(ETIMEDOUT)
|
|---|
| 236 | CASEERR1(ECONNREFUSED)
|
|---|
| 237 | CASEERR1(ELOOP)
|
|---|
| 238 | CASEERR1(ENAMETOOLONG)
|
|---|
| 239 | CASEERR1(EHOSTDOWN)
|
|---|
| 240 | CASEERR1(EHOSTUNREACH)
|
|---|
| 241 |
|
|---|
| 242 | CASEERR1(ENOTEMPTY)
|
|---|
| 243 | // CASEERR(EPROCLIM)
|
|---|
| 244 | // CASEERR(EUSERS)
|
|---|
| 245 | // CASEERR(EDQUOT)
|
|---|
| 246 | // CASEERR(ESTALE)
|
|---|
| 247 | // CASEERR(EREMOTE)
|
|---|
| 248 | // CASEERR(EDISCON)
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | default:
|
|---|
| 252 | dprintf(("WSOCK32: Unknown error condition: %d\n",
|
|---|
| 253 | iError));
|
|---|
| 254 | return iError;
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 | /*****************************************************************************
|
|---|
| 260 | * Name :
|
|---|
| 261 | * Purpose :
|
|---|
| 262 | * Parameters:
|
|---|
| 263 | * Variables :
|
|---|
| 264 | * Result :
|
|---|
| 265 | * Remark :
|
|---|
| 266 | * Status : UNTESTED STUB
|
|---|
| 267 | *
|
|---|
| 268 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 269 | *****************************************************************************/
|
|---|
| 270 |
|
|---|
| 271 | ODINFUNCTION2(int, OS2__WSAFDIsSet, SOCKET, fd,
|
|---|
| 272 | Wfd_set FAR*, set)
|
|---|
| 273 | {
|
|---|
| 274 | int i = set->fd_count;
|
|---|
| 275 |
|
|---|
| 276 | while (i--)
|
|---|
| 277 | if (set->fd_array[i] == fd)
|
|---|
| 278 | return 1;
|
|---|
| 279 |
|
|---|
| 280 | return 0;
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 | /*****************************************************************************
|
|---|
| 285 | * Name :
|
|---|
| 286 | * Purpose :
|
|---|
| 287 | * Parameters:
|
|---|
| 288 | * Variables :
|
|---|
| 289 | * Result :
|
|---|
| 290 | * Remark :
|
|---|
| 291 | * Status : UNTESTED STUB
|
|---|
| 292 | *
|
|---|
| 293 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 294 | *****************************************************************************/
|
|---|
| 295 |
|
|---|
| 296 | ODINFUNCTION3(SOCKET,OS2accept,SOCKET, s,
|
|---|
| 297 | PSOCKADDR, addr,
|
|---|
| 298 | int*, addrlen)
|
|---|
| 299 | {
|
|---|
| 300 | SOCKET rc = accept(s,addr,addrlen);
|
|---|
| 301 |
|
|---|
| 302 | if (rc == INVALID_SOCKET)
|
|---|
| 303 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 304 | else
|
|---|
| 305 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 306 |
|
|---|
| 307 | return rc;
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 | /*****************************************************************************
|
|---|
| 312 | * Name :
|
|---|
| 313 | * Purpose :
|
|---|
| 314 | * Parameters:
|
|---|
| 315 | * Variables :
|
|---|
| 316 | * Result :
|
|---|
| 317 | * Remark :
|
|---|
| 318 | * Status : UNTESTED STUB
|
|---|
| 319 | *
|
|---|
| 320 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 321 | *****************************************************************************/
|
|---|
| 322 |
|
|---|
| 323 | ODINFUNCTION3(int,OS2bind,SOCKET, s,
|
|---|
| 324 | const struct sockaddr *, addr,
|
|---|
| 325 | int, namelen)
|
|---|
| 326 | {
|
|---|
| 327 | int rc = bind(s,(PSOCKADDR)addr,namelen);
|
|---|
| 328 |
|
|---|
| 329 | if (rc < 0)
|
|---|
| 330 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 331 | else
|
|---|
| 332 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 333 | return rc;
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 | /*****************************************************************************
|
|---|
| 338 | * Name :
|
|---|
| 339 | * Purpose :
|
|---|
| 340 | * Parameters:
|
|---|
| 341 | * Variables :
|
|---|
| 342 | * Result :
|
|---|
| 343 | * Remark :
|
|---|
| 344 | * Status : UNTESTED STUB
|
|---|
| 345 | *
|
|---|
| 346 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 347 | *****************************************************************************/
|
|---|
| 348 |
|
|---|
| 349 | ODINFUNCTION1(int,OS2closesocket,SOCKET,s)
|
|---|
| 350 | {
|
|---|
| 351 | int rc = soclose((int)s);
|
|---|
| 352 |
|
|---|
| 353 | if (rc < 0)
|
|---|
| 354 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 355 | else
|
|---|
| 356 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 357 |
|
|---|
| 358 | return rc;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | /*****************************************************************************
|
|---|
| 363 | * Name :
|
|---|
| 364 | * Purpose :
|
|---|
| 365 | * Parameters:
|
|---|
| 366 | * Variables :
|
|---|
| 367 | * Result :
|
|---|
| 368 | * Remark :
|
|---|
| 369 | * Status : UNTESTED STUB
|
|---|
| 370 | *
|
|---|
| 371 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 372 | *****************************************************************************/
|
|---|
| 373 |
|
|---|
| 374 | ODINFUNCTION3(int,OS2connect,SOCKET, s,
|
|---|
| 375 | const struct sockaddr*, name,
|
|---|
| 376 | int, namelen)
|
|---|
| 377 | {
|
|---|
| 378 | int rc = connect(s,
|
|---|
| 379 | (PSOCKADDR)name,
|
|---|
| 380 | namelen);
|
|---|
| 381 |
|
|---|
| 382 | if (rc < 0)
|
|---|
| 383 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 384 | else
|
|---|
| 385 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 386 |
|
|---|
| 387 | return rc;
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | /*****************************************************************************
|
|---|
| 392 | * Name :
|
|---|
| 393 | * Purpose :
|
|---|
| 394 | * Parameters:
|
|---|
| 395 | * Variables :
|
|---|
| 396 | * Result :
|
|---|
| 397 | * Remark :
|
|---|
| 398 | * Status : UNTESTED STUB
|
|---|
| 399 | *
|
|---|
| 400 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 401 | *****************************************************************************/
|
|---|
| 402 |
|
|---|
| 403 | ODINFUNCTION3(int,OS2ioctlsocket,SOCKET, s,
|
|---|
| 404 | long, cmd,
|
|---|
| 405 | u_long*, argp)
|
|---|
| 406 | {
|
|---|
| 407 | int rc = ioctl(s, cmd, (char *)argp, 4);
|
|---|
| 408 |
|
|---|
| 409 | if (rc < 0)
|
|---|
| 410 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 411 | else
|
|---|
| 412 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 413 |
|
|---|
| 414 | return rc;
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 | /*****************************************************************************
|
|---|
| 419 | * Name :
|
|---|
| 420 | * Purpose :
|
|---|
| 421 | * Parameters:
|
|---|
| 422 | * Variables :
|
|---|
| 423 | * Result :
|
|---|
| 424 | * Remark :
|
|---|
| 425 | * Status : UNTESTED STUB
|
|---|
| 426 | *
|
|---|
| 427 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 428 | *****************************************************************************/
|
|---|
| 429 |
|
|---|
| 430 | ODINFUNCTION3(int,OS2getpeername,SOCKET, s,
|
|---|
| 431 | PSOCKADDR,name,
|
|---|
| 432 | int*, namelen)
|
|---|
| 433 | {
|
|---|
| 434 | SOCKET rc = getpeername(s,name,namelen);
|
|---|
| 435 |
|
|---|
| 436 | if (rc == SOCKET_ERROR)
|
|---|
| 437 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 438 | else
|
|---|
| 439 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 440 |
|
|---|
| 441 | return rc;
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 | /*****************************************************************************
|
|---|
| 446 | * Name :
|
|---|
| 447 | * Purpose :
|
|---|
| 448 | * Parameters:
|
|---|
| 449 | * Variables :
|
|---|
| 450 | * Result :
|
|---|
| 451 | * Remark :
|
|---|
| 452 | * Status : UNTESTED STUB
|
|---|
| 453 | *
|
|---|
| 454 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 455 | *****************************************************************************/
|
|---|
| 456 |
|
|---|
| 457 | ODINFUNCTION3(int,OS2getsockname,SOCKET, s,
|
|---|
| 458 | PSOCKADDR,name,
|
|---|
| 459 | int*, namelen)
|
|---|
| 460 | {
|
|---|
| 461 | SOCKET rc = getsockname(s,name,namelen);
|
|---|
| 462 |
|
|---|
| 463 | if (rc == SOCKET_ERROR)
|
|---|
| 464 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 465 | else
|
|---|
| 466 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 467 |
|
|---|
| 468 | return rc;
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 | /*****************************************************************************
|
|---|
| 473 | * Name :
|
|---|
| 474 | * Purpose :
|
|---|
| 475 | * Parameters:
|
|---|
| 476 | * Variables :
|
|---|
| 477 | * Result :
|
|---|
| 478 | * Remark :
|
|---|
| 479 | * Status : UNTESTED STUB
|
|---|
| 480 | *
|
|---|
| 481 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 482 | *****************************************************************************/
|
|---|
| 483 |
|
|---|
| 484 | ODINFUNCTION5(int,OS2getsockopt,SOCKET,s,
|
|---|
| 485 | int, level,
|
|---|
| 486 | int, optname,
|
|---|
| 487 | char*, optval,
|
|---|
| 488 | int*, optlen)
|
|---|
| 489 | {
|
|---|
| 490 | int rc = getsockopt(s,level,optname,optval,optlen);
|
|---|
| 491 |
|
|---|
| 492 | if (rc == SOCKET_ERROR)
|
|---|
| 493 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 494 | else
|
|---|
| 495 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 496 |
|
|---|
| 497 | return rc;
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 | /*****************************************************************************
|
|---|
| 502 | * Name :
|
|---|
| 503 | * Purpose :
|
|---|
| 504 | * Parameters:
|
|---|
| 505 | * Variables :
|
|---|
| 506 | * Result :
|
|---|
| 507 | * Remark :
|
|---|
| 508 | * Status : UNTESTED STUB
|
|---|
| 509 | *
|
|---|
| 510 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 511 | *****************************************************************************/
|
|---|
| 512 |
|
|---|
| 513 | ODINFUNCTION1(u_long,OS2htonl,u_long,hostlong)
|
|---|
| 514 | {
|
|---|
| 515 | return htonl(hostlong);
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | /*****************************************************************************
|
|---|
| 520 | * Name :
|
|---|
| 521 | * Purpose :
|
|---|
| 522 | * Parameters:
|
|---|
| 523 | * Variables :
|
|---|
| 524 | * Result :
|
|---|
| 525 | * Remark :
|
|---|
| 526 | * Status : UNTESTED STUB
|
|---|
| 527 | *
|
|---|
| 528 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 529 | *****************************************************************************/
|
|---|
| 530 |
|
|---|
| 531 | ODINFUNCTION1(u_short,OS2htons,u_short,hostshort)
|
|---|
| 532 | {
|
|---|
| 533 | return htons(hostshort);
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 | /*****************************************************************************
|
|---|
| 538 | * Name :
|
|---|
| 539 | * Purpose :
|
|---|
| 540 | * Parameters:
|
|---|
| 541 | * Variables :
|
|---|
| 542 | * Result :
|
|---|
| 543 | * Remark :
|
|---|
| 544 | * Status : UNTESTED STUB
|
|---|
| 545 | *
|
|---|
| 546 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 547 | *****************************************************************************/
|
|---|
| 548 |
|
|---|
| 549 | ODINFUNCTION1(u_long,OS2inet_addr,const char*, cp)
|
|---|
| 550 | {
|
|---|
| 551 | return inet_addr((char *)cp);
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 | /*****************************************************************************
|
|---|
| 556 | * Name :
|
|---|
| 557 | * Purpose :
|
|---|
| 558 | * Parameters:
|
|---|
| 559 | * Variables :
|
|---|
| 560 | * Result :
|
|---|
| 561 | * Remark :
|
|---|
| 562 | * Status : UNTESTED STUB
|
|---|
| 563 | *
|
|---|
| 564 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 565 | *****************************************************************************/
|
|---|
| 566 |
|
|---|
| 567 | ODINFUNCTION1(char*,OS2inet_ntoa,struct in_addr,in)
|
|---|
| 568 | {
|
|---|
| 569 | return inet_ntoa(in);
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 |
|
|---|
| 573 | /*****************************************************************************
|
|---|
| 574 | * Name :
|
|---|
| 575 | * Purpose :
|
|---|
| 576 | * Parameters:
|
|---|
| 577 | * Variables :
|
|---|
| 578 | * Result :
|
|---|
| 579 | * Remark :
|
|---|
| 580 | * Status : UNTESTED STUB
|
|---|
| 581 | *
|
|---|
| 582 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 583 | *****************************************************************************/
|
|---|
| 584 |
|
|---|
| 585 | ODINFUNCTION2(int,OS2listen,SOCKET,s,
|
|---|
| 586 | int, backlog)
|
|---|
| 587 | {
|
|---|
| 588 | int rc = listen(s,backlog);
|
|---|
| 589 |
|
|---|
| 590 | if (rc < 0)
|
|---|
| 591 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 592 | else
|
|---|
| 593 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 594 |
|
|---|
| 595 | return rc;
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 |
|
|---|
| 599 | /*****************************************************************************
|
|---|
| 600 | * Name :
|
|---|
| 601 | * Purpose :
|
|---|
| 602 | * Parameters:
|
|---|
| 603 | * Variables :
|
|---|
| 604 | * Result :
|
|---|
| 605 | * Remark :
|
|---|
| 606 | * Status : UNTESTED STUB
|
|---|
| 607 | *
|
|---|
| 608 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 609 | *****************************************************************************/
|
|---|
| 610 |
|
|---|
| 611 | ODINFUNCTION1(u_long,OS2ntohl,u_long,netlong)
|
|---|
| 612 | {
|
|---|
| 613 | return ntohl(netlong);
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 | /*****************************************************************************
|
|---|
| 618 | * Name :
|
|---|
| 619 | * Purpose :
|
|---|
| 620 | * Parameters:
|
|---|
| 621 | * Variables :
|
|---|
| 622 | * Result :
|
|---|
| 623 | * Remark :
|
|---|
| 624 | * Status : UNTESTED STUB
|
|---|
| 625 | *
|
|---|
| 626 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 627 | *****************************************************************************/
|
|---|
| 628 |
|
|---|
| 629 | ODINFUNCTION1(u_short,OS2ntohs,u_short,netshort)
|
|---|
| 630 | {
|
|---|
| 631 | return ntohs(netshort);
|
|---|
| 632 | }
|
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 | /*****************************************************************************
|
|---|
| 636 | * Name :
|
|---|
| 637 | * Purpose :
|
|---|
| 638 | * Parameters:
|
|---|
| 639 | * Variables :
|
|---|
| 640 | * Result :
|
|---|
| 641 | * Remark :
|
|---|
| 642 | * Status : UNTESTED STUB
|
|---|
| 643 | *
|
|---|
| 644 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 645 | *****************************************************************************/
|
|---|
| 646 |
|
|---|
| 647 | ODINFUNCTION4(int,OS2recv,SOCKET,s,
|
|---|
| 648 | char*, buf,
|
|---|
| 649 | int, len,
|
|---|
| 650 | int, flags)
|
|---|
| 651 | {
|
|---|
| 652 | int rc = recv(s,buf,len,flags);
|
|---|
| 653 |
|
|---|
| 654 | if (rc < 0)
|
|---|
| 655 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 656 | else
|
|---|
| 657 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 658 |
|
|---|
| 659 | return rc;
|
|---|
| 660 | }
|
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 | /*****************************************************************************
|
|---|
| 664 | * Name :
|
|---|
| 665 | * Purpose :
|
|---|
| 666 | * Parameters:
|
|---|
| 667 | * Variables :
|
|---|
| 668 | * Result :
|
|---|
| 669 | * Remark :
|
|---|
| 670 | * Status : UNTESTED STUB
|
|---|
| 671 | *
|
|---|
| 672 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 673 | *****************************************************************************/
|
|---|
| 674 |
|
|---|
| 675 | ODINFUNCTION6(int,OS2recvfrom,SOCKET, s,
|
|---|
| 676 | char*, buf,
|
|---|
| 677 | int, len,
|
|---|
| 678 | int, flags,
|
|---|
| 679 | PSOCKADDR, from,
|
|---|
| 680 | int*, fromlen)
|
|---|
| 681 | {
|
|---|
| 682 | int rc = recvfrom(s,buf,len,flags,from,fromlen);
|
|---|
| 683 |
|
|---|
| 684 | if (rc < 0)
|
|---|
| 685 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 686 | else
|
|---|
| 687 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 688 |
|
|---|
| 689 | return rc;
|
|---|
| 690 | }
|
|---|
| 691 |
|
|---|
| 692 |
|
|---|
| 693 | /*****************************************************************************
|
|---|
| 694 | * Name :
|
|---|
| 695 | * Purpose :
|
|---|
| 696 | * Parameters:
|
|---|
| 697 | * Variables :
|
|---|
| 698 | * Result :
|
|---|
| 699 | * Remark :
|
|---|
| 700 | * Status : UNTESTED STUB
|
|---|
| 701 | *
|
|---|
| 702 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 703 | *****************************************************************************/
|
|---|
| 704 |
|
|---|
| 705 | #ifdef VV_BSD_SELECT
|
|---|
| 706 |
|
|---|
| 707 | ODINFUNCTION5(int,OS2select,int, nfds,
|
|---|
| 708 | Wfd_set*, readfds,
|
|---|
| 709 | Wfd_set*, writefds,
|
|---|
| 710 | Wfd_set*, exceptfds,
|
|---|
| 711 | const struct Wtimeval*, timeout)
|
|---|
| 712 | {
|
|---|
| 713 | int rc = select(nfds,
|
|---|
| 714 | (fd_set *)readfds,
|
|---|
| 715 | (fd_set *)writefds,
|
|---|
| 716 | (fd_set *)exceptfds,
|
|---|
| 717 | (timeval *)timeout);
|
|---|
| 718 |
|
|---|
| 719 | if (rc == SOCKET_ERROR)
|
|---|
| 720 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 721 | else
|
|---|
| 722 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 723 |
|
|---|
| 724 | return rc;
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 | #else
|
|---|
| 728 | # error OS/2-style select not implemented!
|
|---|
| 729 | #endif
|
|---|
| 730 |
|
|---|
| 731 |
|
|---|
| 732 | /*****************************************************************************
|
|---|
| 733 | * Name :
|
|---|
| 734 | * Purpose :
|
|---|
| 735 | * Parameters:
|
|---|
| 736 | * Variables :
|
|---|
| 737 | * Result :
|
|---|
| 738 | * Remark :
|
|---|
| 739 | * Status : UNTESTED STUB
|
|---|
| 740 | *
|
|---|
| 741 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 742 | *****************************************************************************/
|
|---|
| 743 |
|
|---|
| 744 | ODINFUNCTION4(int,OS2send,SOCKET, s,
|
|---|
| 745 | const char*, buf,
|
|---|
| 746 | int, len,
|
|---|
| 747 | int, flags)
|
|---|
| 748 | {
|
|---|
| 749 | int rc = send(s,(char *)buf,len,flags);
|
|---|
| 750 |
|
|---|
| 751 | if (rc < 0)
|
|---|
| 752 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 753 | else
|
|---|
| 754 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 755 |
|
|---|
| 756 | return rc;
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 |
|
|---|
| 760 | /*****************************************************************************
|
|---|
| 761 | * Name :
|
|---|
| 762 | * Purpose :
|
|---|
| 763 | * Parameters:
|
|---|
| 764 | * Variables :
|
|---|
| 765 | * Result :
|
|---|
| 766 | * Remark :
|
|---|
| 767 | * Status : UNTESTED STUB
|
|---|
| 768 | *
|
|---|
| 769 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 770 | *****************************************************************************/
|
|---|
| 771 |
|
|---|
| 772 | ODINFUNCTION6(int,OS2sendto,SOCKET, s,
|
|---|
| 773 | const char*, buf,
|
|---|
| 774 | int, len,
|
|---|
| 775 | int, flags,
|
|---|
| 776 | const struct sockaddr*, to,
|
|---|
| 777 | int, tolen)
|
|---|
| 778 | {
|
|---|
| 779 | int rc = sendto(s,(char *)buf,len,flags,(PSOCKADDR)to,tolen);
|
|---|
| 780 |
|
|---|
| 781 | if (rc < 0)
|
|---|
| 782 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 783 | else
|
|---|
| 784 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 785 |
|
|---|
| 786 | return rc;
|
|---|
| 787 | }
|
|---|
| 788 |
|
|---|
| 789 |
|
|---|
| 790 | /*****************************************************************************
|
|---|
| 791 | * Name :
|
|---|
| 792 | * Purpose :
|
|---|
| 793 | * Parameters:
|
|---|
| 794 | * Variables :
|
|---|
| 795 | * Result :
|
|---|
| 796 | * Remark :
|
|---|
| 797 | * Status : UNTESTED STUB
|
|---|
| 798 | *
|
|---|
| 799 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 800 | *****************************************************************************/
|
|---|
| 801 |
|
|---|
| 802 | ODINFUNCTION5(int,OS2setsockopt,SOCKET, s,
|
|---|
| 803 | int, level,
|
|---|
| 804 | int, optname,
|
|---|
| 805 | const char*, optval,
|
|---|
| 806 | int, optlen)
|
|---|
| 807 | {
|
|---|
| 808 | struct Wlinger *yy;
|
|---|
| 809 | struct linger xx;
|
|---|
| 810 | int rc;
|
|---|
| 811 |
|
|---|
| 812 | if(level == SOL_SOCKET &&
|
|---|
| 813 | optname == SO_LINGER)
|
|---|
| 814 | {
|
|---|
| 815 | yy = (struct Wlinger *)optval;
|
|---|
| 816 | xx.l_onoff = (int)yy->l_onoff;
|
|---|
| 817 | xx.l_linger = (int)yy->l_linger;
|
|---|
| 818 |
|
|---|
| 819 | rc = setsockopt(s,level,optname,(char *)&xx,optlen);
|
|---|
| 820 | }
|
|---|
| 821 | else
|
|---|
| 822 | rc = setsockopt(s,level,optname,(char *)optval,optlen);
|
|---|
| 823 |
|
|---|
| 824 | if (rc == SOCKET_ERROR)
|
|---|
| 825 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 826 | else
|
|---|
| 827 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 828 |
|
|---|
| 829 | return rc;
|
|---|
| 830 | }
|
|---|
| 831 |
|
|---|
| 832 |
|
|---|
| 833 | /*****************************************************************************
|
|---|
| 834 | * Name :
|
|---|
| 835 | * Purpose :
|
|---|
| 836 | * Parameters:
|
|---|
| 837 | * Variables :
|
|---|
| 838 | * Result :
|
|---|
| 839 | * Remark :
|
|---|
| 840 | * Status : UNTESTED STUB
|
|---|
| 841 | *
|
|---|
| 842 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 843 | *****************************************************************************/
|
|---|
| 844 |
|
|---|
| 845 | ODINFUNCTION2(int,OS2shutdown,SOCKET,s,
|
|---|
| 846 | int, how)
|
|---|
| 847 | {
|
|---|
| 848 | int rc = shutdown(s,how);
|
|---|
| 849 |
|
|---|
| 850 | if (rc == SOCKET_ERROR)
|
|---|
| 851 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 852 | else
|
|---|
| 853 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 854 |
|
|---|
| 855 | return rc;
|
|---|
| 856 | }
|
|---|
| 857 |
|
|---|
| 858 |
|
|---|
| 859 | /*****************************************************************************
|
|---|
| 860 | * Name :
|
|---|
| 861 | * Purpose :
|
|---|
| 862 | * Parameters:
|
|---|
| 863 | * Variables :
|
|---|
| 864 | * Result :
|
|---|
| 865 | * Remark :
|
|---|
| 866 | * Status : UNTESTED STUB
|
|---|
| 867 | *
|
|---|
| 868 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 869 | *****************************************************************************/
|
|---|
| 870 |
|
|---|
| 871 | ODINFUNCTION3(SOCKET,OS2socket,int,af,
|
|---|
| 872 | int,type,
|
|---|
| 873 | int,protocol)
|
|---|
| 874 | {
|
|---|
| 875 | SOCKET rc = socket(af,type,protocol);
|
|---|
| 876 |
|
|---|
| 877 | if (rc == INVALID_SOCKET)
|
|---|
| 878 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 879 | else
|
|---|
| 880 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 881 |
|
|---|
| 882 | return rc;
|
|---|
| 883 | }
|
|---|
| 884 |
|
|---|
| 885 |
|
|---|
| 886 | /*****************************************************************************
|
|---|
| 887 | * Name :
|
|---|
| 888 | * Purpose :
|
|---|
| 889 | * Parameters:
|
|---|
| 890 | * Variables :
|
|---|
| 891 | * Result :
|
|---|
| 892 | * Remark :
|
|---|
| 893 | * Status : UNTESTED STUB
|
|---|
| 894 | *
|
|---|
| 895 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 896 | *****************************************************************************/
|
|---|
| 897 |
|
|---|
| 898 | ODINFUNCTION3(WHOSTENT*,OS2gethostbyaddr,const char*, addr,
|
|---|
| 899 | int, len,
|
|---|
| 900 | int, type)
|
|---|
| 901 | {
|
|---|
| 902 | WHOSTENT *yy;
|
|---|
| 903 | struct hostent *xx;
|
|---|
| 904 | PWSOCKTHREADDATA pwstd;
|
|---|
| 905 |
|
|---|
| 906 | xx = gethostbyaddr((char *)addr,len,type);
|
|---|
| 907 |
|
|---|
| 908 | if(xx == NULL)
|
|---|
| 909 | {
|
|---|
| 910 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 911 | return (WHOSTENT *)NULL;
|
|---|
| 912 | }
|
|---|
| 913 | else
|
|---|
| 914 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 915 |
|
|---|
| 916 | // access current thread wsock data block
|
|---|
| 917 | pwstd = iQueryWsockThreadData();
|
|---|
| 918 |
|
|---|
| 919 | pwstd->whsnt.h_name = xx->h_name;
|
|---|
| 920 | pwstd->whsnt.h_aliases = xx->h_aliases;
|
|---|
| 921 | pwstd->whsnt.h_addrtype = (short)xx->h_addrtype;
|
|---|
| 922 | pwstd->whsnt.h_length = (short)xx->h_length;
|
|---|
| 923 | pwstd->whsnt.h_addr_list = xx->h_addr_list;
|
|---|
| 924 |
|
|---|
| 925 | return &pwstd->whsnt;
|
|---|
| 926 | }
|
|---|
| 927 |
|
|---|
| 928 |
|
|---|
| 929 | /*****************************************************************************
|
|---|
| 930 | * Name :
|
|---|
| 931 | * Purpose :
|
|---|
| 932 | * Parameters:
|
|---|
| 933 | * Variables :
|
|---|
| 934 | * Result :
|
|---|
| 935 | * Remark :
|
|---|
| 936 | * Status : UNTESTED STUB
|
|---|
| 937 | *
|
|---|
| 938 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 939 | *****************************************************************************/
|
|---|
| 940 |
|
|---|
| 941 | ODINFUNCTION1(WHOSTENT*,OS2gethostbyname,const char*,name)
|
|---|
| 942 | {
|
|---|
| 943 | WHOSTENT *yy;
|
|---|
| 944 | struct hostent *xx;
|
|---|
| 945 | PWSOCKTHREADDATA pwstd;
|
|---|
| 946 |
|
|---|
| 947 |
|
|---|
| 948 | xx = gethostbyname((char *)name);
|
|---|
| 949 | if(xx == NULL)
|
|---|
| 950 | {
|
|---|
| 951 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 952 | return (WHOSTENT *)NULL;
|
|---|
| 953 | }
|
|---|
| 954 | else
|
|---|
| 955 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 956 |
|
|---|
| 957 | // access current thread wsock data block
|
|---|
| 958 | pwstd = iQueryWsockThreadData();
|
|---|
| 959 |
|
|---|
| 960 | pwstd->whsnt.h_name = xx->h_name;
|
|---|
| 961 | pwstd->whsnt.h_aliases = xx->h_aliases;
|
|---|
| 962 | pwstd->whsnt.h_addrtype = (short)xx->h_addrtype;
|
|---|
| 963 | pwstd->whsnt.h_length = (short)xx->h_length;
|
|---|
| 964 | pwstd->whsnt.h_addr_list = xx->h_addr_list;
|
|---|
| 965 |
|
|---|
| 966 | return &pwstd->whsnt;
|
|---|
| 967 | }
|
|---|
| 968 |
|
|---|
| 969 |
|
|---|
| 970 | /*****************************************************************************
|
|---|
| 971 | * Name :
|
|---|
| 972 | * Purpose :
|
|---|
| 973 | * Parameters:
|
|---|
| 974 | * Variables :
|
|---|
| 975 | * Result :
|
|---|
| 976 | * Remark :
|
|---|
| 977 | * Status : UNTESTED STUB
|
|---|
| 978 | *
|
|---|
| 979 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 980 | *****************************************************************************/
|
|---|
| 981 |
|
|---|
| 982 | ODINFUNCTION2(int,OS2gethostname,char *,name,
|
|---|
| 983 | int, namelen)
|
|---|
| 984 | {
|
|---|
| 985 | return gethostname(name,namelen);
|
|---|
| 986 | }
|
|---|
| 987 |
|
|---|
| 988 |
|
|---|
| 989 | /*****************************************************************************
|
|---|
| 990 | * Name :
|
|---|
| 991 | * Purpose :
|
|---|
| 992 | * Parameters:
|
|---|
| 993 | * Variables :
|
|---|
| 994 | * Result :
|
|---|
| 995 | * Remark :
|
|---|
| 996 | * Status : UNTESTED STUB
|
|---|
| 997 | *
|
|---|
| 998 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 999 | *****************************************************************************/
|
|---|
| 1000 |
|
|---|
| 1001 | ODINFUNCTION2(WSERVENT*,OS2getservbyport, int, port,
|
|---|
| 1002 | const char*, proto)
|
|---|
| 1003 | {
|
|---|
| 1004 | struct servent *xx;
|
|---|
| 1005 | PWSOCKTHREADDATA pwstd;
|
|---|
| 1006 |
|
|---|
| 1007 | xx = getservbyport(port,(char *)proto);
|
|---|
| 1008 |
|
|---|
| 1009 | if(xx == NULL)
|
|---|
| 1010 | { // this call doesn't generate an error message
|
|---|
| 1011 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 1012 | return (WSERVENT *)NULL;
|
|---|
| 1013 | }
|
|---|
| 1014 | else
|
|---|
| 1015 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 1016 |
|
|---|
| 1017 | // access current thread wsock data block
|
|---|
| 1018 | pwstd = iQueryWsockThreadData();
|
|---|
| 1019 |
|
|---|
| 1020 | pwstd->wsvnt.s_name = xx->s_name;
|
|---|
| 1021 | pwstd->wsvnt.s_aliases = xx->s_aliases;
|
|---|
| 1022 | pwstd->wsvnt.s_port = (short)xx->s_port;
|
|---|
| 1023 | pwstd->wsvnt.s_proto = xx->s_proto;
|
|---|
| 1024 |
|
|---|
| 1025 | return &pwstd->wsvnt;
|
|---|
| 1026 | }
|
|---|
| 1027 |
|
|---|
| 1028 |
|
|---|
| 1029 | /*****************************************************************************
|
|---|
| 1030 | * Name :
|
|---|
| 1031 | * Purpose :
|
|---|
| 1032 | * Parameters:
|
|---|
| 1033 | * Variables :
|
|---|
| 1034 | * Result :
|
|---|
| 1035 | * Remark :
|
|---|
| 1036 | * Status : UNTESTED STUB
|
|---|
| 1037 | *
|
|---|
| 1038 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1039 | *****************************************************************************/
|
|---|
| 1040 |
|
|---|
| 1041 | ODINFUNCTION2(WSERVENT*,OS2getservbyname,const char*,name,
|
|---|
| 1042 | const char*,proto)
|
|---|
| 1043 | {
|
|---|
| 1044 | WSERVENT *yy;
|
|---|
| 1045 | struct servent *xx;
|
|---|
| 1046 | PWSOCKTHREADDATA pwstd;
|
|---|
| 1047 |
|
|---|
| 1048 |
|
|---|
| 1049 | xx = getservbyname((char *)name,(char *)proto);
|
|---|
| 1050 |
|
|---|
| 1051 | if(xx == NULL)
|
|---|
| 1052 | { // this call doesn't generate an error message
|
|---|
| 1053 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 1054 | return (WSERVENT *)NULL;
|
|---|
| 1055 | }
|
|---|
| 1056 | else
|
|---|
| 1057 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 1058 |
|
|---|
| 1059 | // access current thread wsock data block
|
|---|
| 1060 | pwstd = iQueryWsockThreadData();
|
|---|
| 1061 |
|
|---|
| 1062 | pwstd->wsvnt.s_name = xx->s_name;
|
|---|
| 1063 | pwstd->wsvnt.s_aliases = xx->s_aliases;
|
|---|
| 1064 | pwstd->wsvnt.s_port = (short)xx->s_port;
|
|---|
| 1065 | pwstd->wsvnt.s_proto = xx->s_proto;
|
|---|
| 1066 |
|
|---|
| 1067 | return &pwstd->wsvnt;
|
|---|
| 1068 | }
|
|---|
| 1069 |
|
|---|
| 1070 |
|
|---|
| 1071 | /*****************************************************************************
|
|---|
| 1072 | * Name :
|
|---|
| 1073 | * Purpose :
|
|---|
| 1074 | * Parameters:
|
|---|
| 1075 | * Variables :
|
|---|
| 1076 | * Result :
|
|---|
| 1077 | * Remark :
|
|---|
| 1078 | * Status : UNTESTED STUB
|
|---|
| 1079 | *
|
|---|
| 1080 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1081 | *****************************************************************************/
|
|---|
| 1082 |
|
|---|
| 1083 | ODINFUNCTION1(WPROTOENT*,OS2getprotobynumber,int,proto)
|
|---|
| 1084 | {
|
|---|
| 1085 | struct protoent *xx;
|
|---|
| 1086 | PWSOCKTHREADDATA pwstd;
|
|---|
| 1087 |
|
|---|
| 1088 | xx = getprotobynumber(proto);
|
|---|
| 1089 |
|
|---|
| 1090 | if(xx == NULL)
|
|---|
| 1091 | {
|
|---|
| 1092 | // this call doesn't generate an error message
|
|---|
| 1093 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 1094 | return (WPROTOENT *)NULL;
|
|---|
| 1095 | }
|
|---|
| 1096 | else
|
|---|
| 1097 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 1098 |
|
|---|
| 1099 | // access current thread wsock data block
|
|---|
| 1100 | pwstd = iQueryWsockThreadData();
|
|---|
| 1101 |
|
|---|
| 1102 | pwstd->wptnt.p_name = xx->p_name;
|
|---|
| 1103 | pwstd->wptnt.p_aliases = xx->p_aliases;
|
|---|
| 1104 | pwstd->wptnt.p_proto = (short)xx->p_proto;
|
|---|
| 1105 |
|
|---|
| 1106 | return &pwstd->wptnt;
|
|---|
| 1107 | }
|
|---|
| 1108 |
|
|---|
| 1109 |
|
|---|
| 1110 | /*****************************************************************************
|
|---|
| 1111 | * Name :
|
|---|
| 1112 | * Purpose :
|
|---|
| 1113 | * Parameters:
|
|---|
| 1114 | * Variables :
|
|---|
| 1115 | * Result :
|
|---|
| 1116 | * Remark :
|
|---|
| 1117 | * Status : UNTESTED STUB
|
|---|
| 1118 | *
|
|---|
| 1119 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1120 | *****************************************************************************/
|
|---|
| 1121 |
|
|---|
| 1122 | ODINFUNCTION1(WPROTOENT*,OS2getprotobyname,const char*,name)
|
|---|
| 1123 | {
|
|---|
| 1124 | struct protoent *xx;
|
|---|
| 1125 | PWSOCKTHREADDATA pwstd;
|
|---|
| 1126 |
|
|---|
| 1127 | xx = getprotobyname((char *)name);
|
|---|
| 1128 |
|
|---|
| 1129 | if(xx == NULL)
|
|---|
| 1130 | { // this call doesn't generate an error message
|
|---|
| 1131 | WSASetLastError(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 1132 | return (WPROTOENT *)NULL;
|
|---|
| 1133 | }
|
|---|
| 1134 | else
|
|---|
| 1135 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 1136 |
|
|---|
| 1137 | // access current thread wsock data block
|
|---|
| 1138 | pwstd = iQueryWsockThreadData();
|
|---|
| 1139 |
|
|---|
| 1140 | pwstd->wptnt.p_name = xx->p_name;
|
|---|
| 1141 | pwstd->wptnt.p_aliases = xx->p_aliases;
|
|---|
| 1142 | pwstd->wptnt.p_proto = (short)xx->p_proto;
|
|---|
| 1143 |
|
|---|
| 1144 | return &pwstd->wptnt;
|
|---|
| 1145 | }
|
|---|
| 1146 |
|
|---|
| 1147 |
|
|---|
| 1148 | /*****************************************************************************
|
|---|
| 1149 | * Name :
|
|---|
| 1150 | * Purpose :
|
|---|
| 1151 | * Parameters:
|
|---|
| 1152 | * Variables :
|
|---|
| 1153 | * Result :
|
|---|
| 1154 | * Remark :
|
|---|
| 1155 | * Status : UNTESTED STUB
|
|---|
| 1156 | *
|
|---|
| 1157 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1158 | *****************************************************************************/
|
|---|
| 1159 |
|
|---|
| 1160 | ODINFUNCTION2(int,OS2WSAStartup,USHORT, wVersionRequired,
|
|---|
| 1161 | LPWSADATA,lpWsaData)
|
|---|
| 1162 | {
|
|---|
| 1163 | APIRET rc;
|
|---|
| 1164 |
|
|---|
| 1165 | /* Make sure that the version requested is >= 1.1. */
|
|---|
| 1166 | /* The low byte is the major version and the high */
|
|---|
| 1167 | /* byte is the minor version. */
|
|---|
| 1168 |
|
|---|
| 1169 | if ( LOBYTE( wVersionRequired ) < 1 ||
|
|---|
| 1170 | ( LOBYTE( wVersionRequired ) == 1 &&
|
|---|
| 1171 | HIBYTE( wVersionRequired ) < 1 )) {
|
|---|
| 1172 | return WSAVERNOTSUPPORTED;
|
|---|
| 1173 | }
|
|---|
| 1174 |
|
|---|
| 1175 | /* Since we only support 1.1, set both wVersion and */
|
|---|
| 1176 | /* wHighVersion to 1.1. */
|
|---|
| 1177 |
|
|---|
| 1178 | lpWsaData->wVersion = MAKEWORD( 1, 1 );
|
|---|
| 1179 | lpWsaData->wHighVersion = MAKEWORD( 1, 1 );
|
|---|
| 1180 | strcpy(lpWsaData->szDescription,"Win32OS2 WSOCK32.DLL Ver. 1.1");
|
|---|
| 1181 | lpWsaData->iMaxUdpDg = 32767;
|
|---|
| 1182 | lpWsaData->iMaxSockets = 2048;
|
|---|
| 1183 | strcpy(lpWsaData->szSystemStatus,"No Status");
|
|---|
| 1184 |
|
|---|
| 1185 | if(sock_init() == 0)
|
|---|
| 1186 | {
|
|---|
| 1187 | #ifdef DEBUG
|
|---|
| 1188 | WriteLog("WSOCK32: WSAStartup sock_init returned 0\n");
|
|---|
| 1189 | #endif
|
|---|
| 1190 | WSASetLastError(ERROR_SUCCESS);
|
|---|
| 1191 | return 0;
|
|---|
| 1192 | }
|
|---|
| 1193 | else
|
|---|
| 1194 | return(iTranslateSockErrToWSock(sock_errno()));
|
|---|
| 1195 | }
|
|---|
| 1196 |
|
|---|
| 1197 |
|
|---|
| 1198 | /*****************************************************************************
|
|---|
| 1199 | * Name :
|
|---|
| 1200 | * Purpose :
|
|---|
| 1201 | * Parameters:
|
|---|
| 1202 | * Variables :
|
|---|
| 1203 | * Result :
|
|---|
| 1204 | * Remark :
|
|---|
| 1205 | * Status : UNTESTED STUB
|
|---|
| 1206 | *
|
|---|
| 1207 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1208 | *****************************************************************************/
|
|---|
| 1209 |
|
|---|
| 1210 | ODINFUNCTION0(int,OS2WSACleanup)
|
|---|
| 1211 | {
|
|---|
| 1212 | return 0;
|
|---|
| 1213 | }
|
|---|
| 1214 |
|
|---|
| 1215 |
|
|---|
| 1216 | /*****************************************************************************
|
|---|
| 1217 | * Name :
|
|---|
| 1218 | * Purpose :
|
|---|
| 1219 | * Parameters:
|
|---|
| 1220 | * Variables :
|
|---|
| 1221 | * Result :
|
|---|
| 1222 | * Remark :
|
|---|
| 1223 | * Status : UNTESTED STUB
|
|---|
| 1224 | *
|
|---|
| 1225 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1226 | *****************************************************************************/
|
|---|
| 1227 |
|
|---|
| 1228 | ODINPROCEDURE1(WSASetLastError,int,iError)
|
|---|
| 1229 | {
|
|---|
| 1230 | PWSOCKTHREADDATA pwstd = iQueryWsockThreadData();
|
|---|
| 1231 | pwstd->dwLastError = iError;
|
|---|
| 1232 | }
|
|---|
| 1233 |
|
|---|
| 1234 |
|
|---|
| 1235 | /*****************************************************************************
|
|---|
| 1236 | * Name :
|
|---|
| 1237 | * Purpose :
|
|---|
| 1238 | * Parameters:
|
|---|
| 1239 | * Variables :
|
|---|
| 1240 | * Result :
|
|---|
| 1241 | * Remark :
|
|---|
| 1242 | * Status : UNTESTED STUB
|
|---|
| 1243 | *
|
|---|
| 1244 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1245 | *****************************************************************************/
|
|---|
| 1246 |
|
|---|
| 1247 | ODINFUNCTION0(int,WSAGetLastError)
|
|---|
| 1248 | {
|
|---|
| 1249 | PWSOCKTHREADDATA pwstd = iQueryWsockThreadData();
|
|---|
| 1250 | return(pwstd->dwLastError);
|
|---|
| 1251 | }
|
|---|
| 1252 |
|
|---|
| 1253 |
|
|---|
| 1254 | /*****************************************************************************
|
|---|
| 1255 | * Name :
|
|---|
| 1256 | * Purpose :
|
|---|
| 1257 | * Parameters:
|
|---|
| 1258 | * Variables :
|
|---|
| 1259 | * Result :
|
|---|
| 1260 | * Remark :
|
|---|
| 1261 | * Status : UNTESTED STUB
|
|---|
| 1262 | *
|
|---|
| 1263 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1264 | *****************************************************************************/
|
|---|
| 1265 |
|
|---|
| 1266 | ODINFUNCTION0(int,OS2WSAUnhookBlockingHook)
|
|---|
| 1267 | {
|
|---|
| 1268 | dprintf(("WSOCK32: WSAUnhookBlockingHook unimplemented\n"));
|
|---|
| 1269 |
|
|---|
| 1270 | return -5000; //WSAUnhookBlockingHook();
|
|---|
| 1271 | }
|
|---|
| 1272 |
|
|---|
| 1273 |
|
|---|
| 1274 | /*****************************************************************************
|
|---|
| 1275 | * Name :
|
|---|
| 1276 | * Purpose :
|
|---|
| 1277 | * Parameters:
|
|---|
| 1278 | * Variables :
|
|---|
| 1279 | * Result :
|
|---|
| 1280 | * Remark :
|
|---|
| 1281 | * Status : UNTESTED STUB
|
|---|
| 1282 | *
|
|---|
| 1283 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1284 | *****************************************************************************/
|
|---|
| 1285 |
|
|---|
| 1286 | ODINFUNCTION1(PROC,OS2WSASetBlockingHook,PROC,lpBlockFund)
|
|---|
| 1287 | {
|
|---|
| 1288 | dprintf(("WSOCK32: WSASetBlockingHook Unimplemented\n"));
|
|---|
| 1289 | return (PROC)NULL;
|
|---|
| 1290 | }
|
|---|
| 1291 |
|
|---|
| 1292 |
|
|---|
| 1293 | /*****************************************************************************
|
|---|
| 1294 | * Name :
|
|---|
| 1295 | * Purpose :
|
|---|
| 1296 | * Parameters:
|
|---|
| 1297 | * Variables :
|
|---|
| 1298 | * Result :
|
|---|
| 1299 | * Remark :
|
|---|
| 1300 | * Status : UNTESTED STUB
|
|---|
| 1301 | *
|
|---|
| 1302 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1303 | *****************************************************************************/
|
|---|
| 1304 |
|
|---|
| 1305 | ODINFUNCTION0(int,OS2WSACancelBlockingCall)
|
|---|
| 1306 | {
|
|---|
| 1307 | dprintf(("WSOCK32: WSACancelBlockingCall unimplemented\n"));
|
|---|
| 1308 |
|
|---|
| 1309 | return -5000; //WSACancelBlockingCall();
|
|---|
| 1310 | }
|
|---|
| 1311 |
|
|---|
| 1312 |
|
|---|
| 1313 | /*****************************************************************************
|
|---|
| 1314 | * Name :
|
|---|
| 1315 | * Purpose :
|
|---|
| 1316 | * Parameters:
|
|---|
| 1317 | * Variables :
|
|---|
| 1318 | * Result :
|
|---|
| 1319 | * Remark :
|
|---|
| 1320 | * Status : UNTESTED STUB
|
|---|
| 1321 | *
|
|---|
| 1322 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1323 | *****************************************************************************/
|
|---|
| 1324 |
|
|---|
| 1325 | ODINFUNCTION4(int, OS2WSARecvEx, SOCKET, s,
|
|---|
| 1326 | char FAR*, buf,
|
|---|
| 1327 | int, len,
|
|---|
| 1328 | int FAR *,flags)
|
|---|
| 1329 | {
|
|---|
| 1330 | dprintf(("WSOCK32: WSARecvEx not implemented.\n"));
|
|---|
| 1331 |
|
|---|
| 1332 | // return WSARecvEx(s,buf,len,flags);
|
|---|
| 1333 | return 0;
|
|---|
| 1334 | }
|
|---|
| 1335 |
|
|---|
| 1336 |
|
|---|
| 1337 | /*****************************************************************************
|
|---|
| 1338 | * Name :
|
|---|
| 1339 | * Purpose :
|
|---|
| 1340 | * Parameters:
|
|---|
| 1341 | * Variables :
|
|---|
| 1342 | * Result :
|
|---|
| 1343 | * Remark :
|
|---|
| 1344 | * Status : UNTESTED STUB
|
|---|
| 1345 | *
|
|---|
| 1346 | * Author : Patrick Haller [Tue, 1998/06/16 23:00]
|
|---|
| 1347 | *****************************************************************************/
|
|---|
| 1348 |
|
|---|
| 1349 | ODINPROCEDURE2(OS2s_perror, char*, pszMessage,
|
|---|
| 1350 | void*, pUnknown)
|
|---|
| 1351 | {
|
|---|
| 1352 | perror(pszMessage);
|
|---|
| 1353 | }
|
|---|
| 1354 |
|
|---|
| 1355 |
|
|---|