Skip the RV printing test under threads until fixed.
[p5sagit/p5-mst-13.2.git] / NetWare / nw5sck.c
CommitLineData
2986a63f 1
2/*
3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
10/*
8dbfbba0 11 * FILENAME : nw5sck.c
12 * DESCRIPTION : Socket related functions.
13 * Author : SGP
14 * Date : January 2001.
15 * Date Modified: June 26th 2001.
2986a63f 16 */
17
18
19
20#include "EXTERN.h"
21#include "perl.h"
22
2986a63f 23#include "nw5iop.h"
24#include "nw5sck.h"
25#include <fcntl.h>
26#include <sys/stat.h>
27
2986a63f 28u_long
29nw_htonl(u_long hostlong)
30{
31 return htonl(hostlong);
32}
33
34u_short
35nw_htons(u_short hostshort)
36{
37 return htons(hostshort);
38}
39
40u_long
41nw_ntohl(u_long netlong)
42{
43 return ntohl(netlong);
44}
45
46u_short
47nw_ntohs(u_short netshort)
48{
49 return ntohs(netshort);
50}
51
52SOCKET
53nw_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
54{
55 return ((SOCKET)(accept(s, addr, addrlen)));
56}
57
58int
59nw_bind(SOCKET s, const struct sockaddr *addr, int addrlen)
60{
61 return ((int)bind(s, (struct sockaddr *)addr, addrlen));
62
63}
64
65int
66nw_connect(SOCKET s, const struct sockaddr *addr, int addrlen)
67{
68 return((int)connect(s, (struct sockaddr *)addr, addrlen));
69}
70
71void
72nw_endhostent()
73{
74 endhostent();
75}
76
77void
78nw_endnetent()
79{
80 endnetent();
81}
82
83void
84nw_endprotoent()
85{
86 endprotoent();
87}
88
89void
90nw_endservent()
91{
92 endservent();
93}
94
95struct hostent *
96nw_gethostent()
97{
98 return(gethostent());
99}
100
101struct netent *
102nw_getnetent(void)
103{
104 return ((struct netent *) getnetent());
105}
106
107struct protoent *
108nw_getprotoent(void)
109{
110 return ((struct protoent *) getprotoent());
111}
112
113struct hostent *
114nw_gethostbyname(const char *name)
115{
116 return(gethostbyname((char*)name));
117}
118
119int
120nw_gethostname(char *name, int len)
121{
122 return(gethostname(name, len));
123}
124
125struct hostent *
126nw_gethostbyaddr(const char *addr, int len, int type)
127{
128 return(gethostbyaddr((char*)addr, len, type));
129}
130
131struct netent *
132nw_getnetbyaddr(long net, int type)
133{
134 return(getnetbyaddr(net,type));
135}
136
137struct netent *
138nw_getnetbyname(char *name)
139{
140 return (struct netent *)getnetbyname(name);
141}
142
143int
144nw_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen)
145{
146 return((int)getpeername(s, addr, addrlen));
147}
148
149struct protoent *
150nw_getprotobyname(const char *name)
151{
152 return ((struct protoent *)getprotobyname((char*)name));
153}
154
155struct protoent *
156nw_getprotobynumber(int num)
157{
158 return ((struct protoent *)getprotobynumber(num));
159}
160
161struct servent *
162nw_getservbyname(const char *name, const char *proto)
163{
8dbfbba0 164 return (struct servent *)getservbyname((char*)name, (char*)proto);
2986a63f 165}
166
167
168struct servent *
169nw_getservbyport(int port, const char *proto)
170{
8dbfbba0 171 return (struct servent *)getservbyport(port, (char*)proto);
2986a63f 172}
173
174struct servent *
175nw_getservent(void)
176{
177 return (struct servent *) getservent();
178}
179
180void
181nw_sethostent(int stayopen)
182{
183 sethostent(stayopen);
184}
185
186void
187nw_setnetent(int stayopen)
188{
189 setnetent(stayopen);
190}
191
192void
193nw_setprotoent(int stayopen)
194{
195 setprotoent(stayopen);
196}
197
198void
199nw_setservent(int stayopen)
200{
201 setservent(stayopen);
202}
203
204int
225a5dca 205nw_setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen)
206{
8dbfbba0 207 return setsockopt(s, level, optname, (char*)optval, optlen);
225a5dca 208}
209
210int
2986a63f 211nw_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen)
212{
213 return getsockname(s, addr, addrlen);
214}
215
216int
217nw_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen)
218{
219 return ((int)getsockopt(s, level, optname, optval, optlen));
220}
221
222unsigned long
223nw_inet_addr(const char *cp)
224{
225 return inet_addr((char*)cp);
226}
227
2986a63f 228SOCKET
229nw_socket(int af, int type, int protocol)
230{
231 SOCKET s;
232
233#ifndef USE_SOCKETS_AS_HANDLES
234 s = socket(af, type, protocol);
235#else
2986a63f 236 if((s = socket(af, type, protocol)) == INVALID_SOCKET)
237 //errno = WSAGetLastError();
238 else
239 s = s;
240#endif /* USE_SOCKETS_AS_HANDLES */
241
242 return s;
243}
244
245int
246nw_listen(SOCKET s, int backlog)
247{
248 return(listen(s, backlog));
249}
250
251int
252nw_send(SOCKET s, const char *buf, int len, int flags)
253{
254 return(send(s,(char*)buf,len,flags));
255}
256
257int
258nw_recv(SOCKET s, char *buf, int len, int flags)
259{
260 return (recv(s, buf, len, flags));
261}
262
263int
264nw_sendto(SOCKET s, const char *buf, int len, int flags,
265 const struct sockaddr *to, int tolen)
266{
267 return(sendto(s, (char*)buf, len, flags, (struct sockaddr *)to, tolen));
268}
269
270int
271nw_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
272{
273 int r;
274 int frombufsize = *fromlen;
275
276 r = recvfrom(s, buf, len, flags, from, fromlen);
277 //Not sure if the is required - chksgp
278 if (r && frombufsize == *fromlen)
279 (void)nw_getpeername(s, from, fromlen);
280 return r;
281}
282
283int
284nw_select(int nfds, fd_set* rd, fd_set* wr, fd_set* ex, const struct timeval* timeout)
285{
286 return(select(nfds, rd, wr, ex, (struct timeval*)timeout));
287}
288
289int
290nw_shutdown(SOCKET s, int how)
291{
292 return (shutdown(s, how));
293}
294