source: trunk/src/wsock32/socketwrap.h@ 7461

Last change on this file since 7461 was 7461, checked in by sandervl, 23 years ago

added more FS wrapper macros

File size: 11.2 KB
Line 
1#ifndef __SOCKETWRAP_H__
2#define __SOCKETWRAP_H__
3
4#include <sys\socket.h>
5#include <sys\ioctl.h>
6#include <netdb.h>
7#include <netinet\in.h>
8#include <netinet\tcp.h>
9#include <nerrno.h>
10
11inline int _accept(int a, struct sockaddr *b, int *c)
12{
13 int yyrc;
14 USHORT sel = RestoreOS2FS();
15
16 yyrc = accept(a, b, c);
17 SetFS(sel);
18
19 return yyrc;
20}
21
22#undef accept
23#define accept _accept
24
25inline void _addsockettolist(int a)
26{
27 USHORT sel = RestoreOS2FS();
28
29 addsockettolist(a);
30 SetFS(sel);
31}
32
33#undef addsockettolist
34#define addsockettolist _addsockettolist
35
36inline int _bind(int a, struct sockaddr *b, int c)
37{
38 int yyrc;
39 USHORT sel = RestoreOS2FS();
40
41 yyrc = bind(a, b, c);
42 SetFS(sel);
43
44 return yyrc;
45}
46
47#undef bind
48#define bind _bind
49
50inline int _connect(int a, struct sockaddr *b, int c)
51{
52 int yyrc;
53 USHORT sel = RestoreOS2FS();
54
55 yyrc = connect(a, b, c);
56 SetFS(sel);
57
58 return yyrc;
59}
60
61#undef connect
62#define connect _connect
63
64inline int _gethostid()
65{
66 int yyrc;
67 USHORT sel = RestoreOS2FS();
68
69 yyrc = gethostid();
70 SetFS(sel);
71
72 return yyrc;
73}
74
75#undef gethostid
76#define gethostid _gethostid
77
78inline int _getpeername(int a, struct sockaddr *b, int *c)
79{
80 int yyrc;
81 USHORT sel = RestoreOS2FS();
82
83 yyrc = getpeername(a, b, c);
84 SetFS(sel);
85
86 return yyrc;
87}
88
89#undef getpeername
90#define getpeername _getpeername
91
92inline int _getsockname(int a, struct sockaddr *b, int *c)
93{
94 int yyrc;
95 USHORT sel = RestoreOS2FS();
96
97 yyrc = getsockname(a, b, c);
98 SetFS(sel);
99
100 return yyrc;
101}
102
103#undef getsockname
104#define getsockname _getsockname
105
106inline int _getsockopt(int a, int b, int c, char *d, int *e)
107{
108 int yyrc;
109 USHORT sel = RestoreOS2FS();
110
111 yyrc = getsockopt(a, b, c, d, e);
112 SetFS(sel);
113
114 return yyrc;
115}
116
117#undef getsockopt
118#define getsockopt _getsockopt
119
120inline int _ioctl(int a, int b, char *c, int d)
121{
122 int yyrc;
123 USHORT sel = RestoreOS2FS();
124
125 yyrc = ioctl(a, b, c, d);
126 SetFS(sel);
127
128 return yyrc;
129}
130
131#undef ioctl
132#define ioctl _ioctl
133
134inline int _listen(int a, int b)
135{
136 int yyrc;
137 USHORT sel = RestoreOS2FS();
138
139 yyrc = listen(a, b);
140 SetFS(sel);
141
142 return yyrc;
143}
144
145#undef listen
146#define listen _listen
147
148inline int _recvmsg(int a, struct msghdr *b, int c)
149{
150 int yyrc;
151 USHORT sel = RestoreOS2FS();
152
153 yyrc = recvmsg(a, b, c);
154 SetFS(sel);
155
156 return yyrc;
157}
158
159#undef recvmsg
160#define recvmsg _recvmsg
161
162inline int _recv(int a, char *b, int c, int d)
163{
164 int yyrc;
165 USHORT sel = RestoreOS2FS();
166
167 yyrc = recv(a, b, c, d);
168 SetFS(sel);
169
170 return yyrc;
171}
172
173#undef recv
174#define recv _recv
175
176inline int _recvfrom(int a, char *b, int c, int d, struct sockaddr *e, int *f)
177{
178 int yyrc;
179 USHORT sel = RestoreOS2FS();
180
181 yyrc = recvfrom(a, b, c, d, e, f);
182 SetFS(sel);
183
184 return yyrc;
185}
186
187#undef recvfrom
188#define recvfrom _recvfrom
189
190inline int _removesocketfromlist(int a)
191{
192 int yyrc;
193 USHORT sel = RestoreOS2FS();
194
195 yyrc = removesocketfromlist(a);
196 SetFS(sel);
197
198 return yyrc;
199}
200
201#undef removesocketfromlist
202#define removesocketfromlist _removesocketfromlist
203
204inline int _select(int *a, int b, int c, int d, long e)
205{
206 int yyrc;
207 USHORT sel = RestoreOS2FS();
208
209 yyrc = select(a, b, c, d, e);
210 SetFS(sel);
211
212 return yyrc;
213}
214
215#undef select
216#define select _select
217
218inline int _send(int a, char *b, int c, int d)
219{
220 int yyrc;
221 USHORT sel = RestoreOS2FS();
222
223 yyrc = send(a, b, c, d);
224 SetFS(sel);
225
226 return yyrc;
227}
228
229#undef send
230#define send _send
231
232inline int _sendmsg(int a, struct msghdr *b, int c)
233{
234 int yyrc;
235 USHORT sel = RestoreOS2FS();
236
237 yyrc = sendmsg(a, b, c);
238 SetFS(sel);
239
240 return yyrc;
241}
242
243#undef sendmsg
244#define sendmsg _sendmsg
245
246inline int _sendto(int a, char *b, int c, int d, struct sockaddr *e, int f)
247{
248 int yyrc;
249 USHORT sel = RestoreOS2FS();
250
251 yyrc = sendto(a, b, c, d, e, f);
252 SetFS(sel);
253
254 return yyrc;
255}
256
257#undef sendto
258#define sendto _sendto
259
260inline int _setsockopt(int a, int b, int c, char *d, int e)
261{
262 int yyrc;
263 USHORT sel = RestoreOS2FS();
264
265 yyrc = setsockopt(a, b, c, d, e);
266 SetFS(sel);
267
268 return yyrc;
269}
270
271#undef setsockopt
272#define setsockopt _setsockopt
273
274inline int _sock_init()
275{
276 int yyrc;
277 USHORT sel = RestoreOS2FS();
278
279 yyrc = sock_init();
280 SetFS(sel);
281
282 return yyrc;
283}
284
285#undef sock_init
286#define sock_init _sock_init
287
288inline int _sock_errno()
289{
290 int yyrc;
291 USHORT sel = RestoreOS2FS();
292
293 yyrc = sock_errno();
294 SetFS(sel);
295
296 return yyrc;
297}
298
299#undef sock_errno
300#define sock_errno _sock_errno
301
302inline void _psock_errno(char *a)
303{
304 USHORT sel = RestoreOS2FS();
305
306 psock_errno(a);
307 SetFS(sel);
308}
309
310#undef psock_errno
311#define psock_errno _psock_errno
312
313inline int _socket(int a, int b, int c)
314{
315 int yyrc;
316 USHORT sel = RestoreOS2FS();
317
318 yyrc = socket(a, b, c);
319 SetFS(sel);
320
321 return yyrc;
322}
323
324#undef socket
325#define socket _socket
326
327inline int _soclose(int a)
328{
329 int yyrc;
330 USHORT sel = RestoreOS2FS();
331
332 yyrc = soclose(a);
333 SetFS(sel);
334
335 return yyrc;
336}
337
338#undef soclose
339#define soclose _soclose
340
341inline int _so_cancel(int a)
342{
343 int yyrc;
344 USHORT sel = RestoreOS2FS();
345
346 yyrc = so_cancel(a);
347 SetFS(sel);
348
349 return yyrc;
350}
351
352#undef so_cancel
353#define so_cancel _so_cancel
354
355inline int _readv(int a, struct iovec *b, int c)
356{
357 int yyrc;
358 USHORT sel = RestoreOS2FS();
359
360 yyrc = readv(a, b, c);
361 SetFS(sel);
362
363 return yyrc;
364}
365
366#undef readv
367#define readv _readv
368
369inline int _writev(int a, struct iovec *b, int c)
370{
371 int yyrc;
372 USHORT sel = RestoreOS2FS();
373
374 yyrc = writev(a, b, c);
375 SetFS(sel);
376
377 return yyrc;
378}
379
380#undef writev
381#define writev _writev
382
383inline int _shutdown(int a, int b)
384{
385 int yyrc;
386 USHORT sel = RestoreOS2FS();
387
388 yyrc = shutdown(a, b);
389 SetFS(sel);
390
391 return yyrc;
392}
393
394#undef shutdown
395#define shutdown _shutdown
396
397inline int _Raccept(int a, struct sockaddr *b, int *c)
398{
399 int yyrc;
400 USHORT sel = RestoreOS2FS();
401
402 yyrc = Raccept(a, b, c);
403 SetFS(sel);
404
405 return yyrc;
406}
407
408#undef Raccept
409#define Raccept _Raccept
410
411inline int _Rbind(int a, struct sockaddr_in *b, int c, struct sockaddr_in *d)
412{
413 int yyrc;
414 USHORT sel = RestoreOS2FS();
415
416 yyrc = Rbind(a, b, c, d);
417 SetFS(sel);
418
419 return yyrc;
420}
421
422#undef Rbind
423#define Rbind _Rbind
424
425inline int _Rconnect(int a, const struct sockaddr *b, int c)
426{
427 int yyrc;
428 USHORT sel = RestoreOS2FS();
429
430 yyrc = Rconnect(a, b, c);
431 SetFS(sel);
432
433 return yyrc;
434}
435
436#undef Rconnect
437#define Rconnect _Rconnect
438
439inline int _Rgetsockname(int a, struct sockaddr *b, int *c)
440{
441 int yyrc;
442 USHORT sel = RestoreOS2FS();
443
444 yyrc = Rgetsockname(a, b, c);
445 SetFS(sel);
446
447 return yyrc;
448}
449
450#undef Rgetsockname
451#define Rgetsockname _Rgetsockname
452
453inline int _Rlisten(int a, int b)
454{
455 int yyrc;
456 USHORT sel = RestoreOS2FS();
457
458 yyrc = Rlisten(a, b);
459 SetFS(sel);
460
461 return yyrc;
462}
463
464#undef Rlisten
465#define Rlisten _Rlisten
466
467inline int _gethostname(char *a, int b)
468{
469 int yyrc;
470 USHORT sel = RestoreOS2FS();
471
472 yyrc = gethostname(a, b);
473 SetFS(sel);
474
475 return yyrc;
476}
477
478#undef gethostname
479#define gethostname _gethostname
480
481inline struct hostent *_gethostbyname(char *a)
482{
483 struct hostent * yyrc;
484 USHORT sel = RestoreOS2FS();
485
486 yyrc = gethostbyname(a);
487 SetFS(sel);
488
489 return yyrc;
490}
491
492#undef gethostbyname
493#define gethostbyname _gethostbyname
494
495inline struct hostent *_gethostbyaddr(char *a, int b, int c)
496{
497 struct hostent * yyrc;
498 USHORT sel = RestoreOS2FS();
499
500 yyrc = gethostbyaddr(a, b, c);
501 SetFS(sel);
502
503 return yyrc;
504}
505
506#undef gethostbyaddr
507#define gethostbyaddr _gethostbyaddr
508
509inline struct netent *_getnetbyname(char *a)
510{
511 struct netent * yyrc;
512 USHORT sel = RestoreOS2FS();
513
514 yyrc = getnetbyname(a);
515 SetFS(sel);
516
517 return yyrc;
518}
519
520#undef getnetbyname
521#define getnetbyname _getnetbyname
522
523inline struct netent *_getnetbyaddr(unsigned a, int b)
524{
525 struct netent * yyrc;
526 USHORT sel = RestoreOS2FS();
527
528 yyrc = getnetbyaddr(a, b);
529 SetFS(sel);
530
531 return yyrc;
532}
533
534#undef getnetbyaddr
535#define getnetbyaddr _getnetbyaddr
536
537inline struct servent *_getservbyname(char *a, char *b)
538{
539 struct servent * yyrc;
540 USHORT sel = RestoreOS2FS();
541
542 yyrc = getservbyname(a, b);
543 SetFS(sel);
544
545 return yyrc;
546}
547
548#undef getservbyname
549#define getservbyname _getservbyname
550
551inline struct servent *_getservbyport(int a, char *b)
552{
553 struct servent * yyrc;
554 USHORT sel = RestoreOS2FS();
555
556 yyrc = getservbyport(a, b);
557 SetFS(sel);
558
559 return yyrc;
560}
561
562#undef getservbyport
563#define getservbyport _getservbyport
564
565inline struct protoent *_getprotobyname(char *a)
566{
567 struct protoent * yyrc;
568 USHORT sel = RestoreOS2FS();
569
570 yyrc = getprotobyname(a);
571 SetFS(sel);
572
573 return yyrc;
574}
575
576#undef getprotobyname
577#define getprotobyname _getprotobyname
578
579inline struct protoent *_getprotobynumber(int a)
580{
581 struct protoent * yyrc;
582 USHORT sel = RestoreOS2FS();
583
584 yyrc = getprotobynumber(a);
585 SetFS(sel);
586
587 return yyrc;
588}
589
590#undef getprotobynumber
591#define getprotobynumber _getprotobynumber
592
593inline void _sethostent(int a)
594{
595 USHORT sel = RestoreOS2FS();
596
597 sethostent(a);
598 SetFS(sel);
599}
600
601#undef sethostent
602#define sethostent _sethostent
603
604inline struct hostent *_gethostent()
605{
606 struct hostent * yyrc;
607 USHORT sel = RestoreOS2FS();
608
609 yyrc = gethostent();
610 SetFS(sel);
611
612 return yyrc;
613}
614
615#undef gethostent
616#define gethostent _gethostent
617
618inline void _endhostent()
619{
620 USHORT sel = RestoreOS2FS();
621
622 endhostent();
623 SetFS(sel);
624}
625
626#undef endhostent
627#define endhostent _endhostent
628
629inline void _setnetent(int a)
630{
631 USHORT sel = RestoreOS2FS();
632
633 setnetent(a);
634 SetFS(sel);
635}
636
637#undef setnetent
638#define setnetent _setnetent
639
640inline struct netent *_getnetent()
641{
642 struct netent * yyrc;
643 USHORT sel = RestoreOS2FS();
644
645 yyrc = getnetent();
646 SetFS(sel);
647
648 return yyrc;
649}
650
651#undef getnetent
652#define getnetent _getnetent
653
654inline void _endnetent()
655{
656 USHORT sel = RestoreOS2FS();
657
658 endnetent();
659 SetFS(sel);
660}
661
662#undef endnetent
663#define endnetent _endnetent
664
665inline void _setprotoent(int a)
666{
667 USHORT sel = RestoreOS2FS();
668
669 setprotoent(a);
670 SetFS(sel);
671}
672
673#undef setprotoent
674#define setprotoent _setprotoent
675
676inline struct protoent *_getprotoent()
677{
678 struct protoent * yyrc;
679 USHORT sel = RestoreOS2FS();
680
681 yyrc = getprotoent();
682 SetFS(sel);
683
684 return yyrc;
685}
686
687#undef getprotoent
688#define getprotoent _getprotoent
689
690inline void _endprotoent()
691{
692 USHORT sel = RestoreOS2FS();
693
694 endprotoent();
695 SetFS(sel);
696}
697
698#undef endprotoent
699#define endprotoent _endprotoent
700
701inline void _setservent(int a)
702{
703 USHORT sel = RestoreOS2FS();
704
705 setservent(a);
706 SetFS(sel);
707}
708
709#undef setservent
710#define setservent _setservent
711
712inline struct servent *_getservent()
713{
714 struct servent * yyrc;
715 USHORT sel = RestoreOS2FS();
716
717 yyrc = getservent();
718 SetFS(sel);
719
720 return yyrc;
721}
722
723#undef getservent
724#define getservent _getservent
725
726inline void _endservent()
727{
728 USHORT sel = RestoreOS2FS();
729
730 endservent();
731 SetFS(sel);
732}
733
734#undef endservent
735#define endservent _endservent
736
737inline int _tcp_h_errno()
738{
739 int yyrc;
740 USHORT sel = RestoreOS2FS();
741
742 yyrc = tcp_h_errno();
743 SetFS(sel);
744
745 return yyrc;
746}
747
748#undef tcp_h_errno
749#define tcp_h_errno _tcp_h_errno
750
751inline struct hostent *_Rgethostbyname(char *a)
752{
753 struct hostent * yyrc;
754 USHORT sel = RestoreOS2FS();
755
756 yyrc = Rgethostbyname(a);
757 SetFS(sel);
758
759 return yyrc;
760}
761
762#undef Rgethostbyname
763#define Rgethostbyname _Rgethostbyname
764
765
766#endif //__SOCKETWRAP_H__
767
768
Note: See TracBrowser for help on using the repository browser.