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 |
|
---|
11 | inline 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 |
|
---|
25 | inline 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 |
|
---|
36 | inline 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 |
|
---|
50 | inline 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 |
|
---|
64 | inline 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 |
|
---|
78 | inline 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 |
|
---|
92 | inline 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 |
|
---|
106 | inline 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 |
|
---|
120 | inline 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 |
|
---|
134 | inline 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 |
|
---|
148 | inline 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 |
|
---|
162 | inline 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 |
|
---|
176 | inline 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 |
|
---|
190 | inline 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 |
|
---|
204 | inline 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 |
|
---|
218 | inline 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 |
|
---|
232 | inline 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 |
|
---|
246 | inline 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 |
|
---|
260 | inline 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 |
|
---|
274 | inline 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 |
|
---|
288 | inline 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 |
|
---|
302 | inline 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 |
|
---|
313 | inline 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 |
|
---|
327 | inline 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 |
|
---|
341 | inline 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 |
|
---|
355 | inline 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 |
|
---|
369 | inline 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 |
|
---|
383 | inline 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 |
|
---|
397 | inline 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 |
|
---|
411 | inline 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 |
|
---|
425 | inline 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 |
|
---|
439 | inline 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 |
|
---|
453 | inline 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 |
|
---|
467 |
|
---|
468 | #endif //__SOCKETWRAP_H__
|
---|
469 |
|
---|
470 |
|
---|