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