source: for-distributions/trunk/bin/windows/perl/lib/CORE/sys/socket.h@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

File size: 5.7 KB
Line 
1/* sys/socket.h */
2
3/* djl */
4/* Provide UNIX compatibility */
5
6#ifndef _INC_SYS_SOCKET
7#define _INC_SYS_SOCKET
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define WIN32_LEAN_AND_MEAN
14#ifdef __GNUC__
15# define Win32_Winsock
16#endif
17#include <windows.h>
18
19/* Too late to include winsock2.h if winsock.h has already been loaded */
20#ifndef _WINSOCKAPI_
21# include <winsock2.h>
22#endif
23
24#include "win32.h"
25
26#define ENOTSOCK WSAENOTSOCK
27
28#ifdef USE_SOCKETS_AS_HANDLES
29
30#ifndef PERL_FD_SETSIZE
31#define PERL_FD_SETSIZE 64
32#endif
33
34#define PERL_BITS_PER_BYTE 8
35#define PERL_NFDBITS (sizeof(Perl_fd_mask)*PERL_BITS_PER_BYTE)
36
37typedef int Perl_fd_mask;
38
39typedef struct Perl_fd_set {
40 Perl_fd_mask bits[(PERL_FD_SETSIZE+PERL_NFDBITS-1)/PERL_NFDBITS];
41} Perl_fd_set;
42
43#define PERL_FD_CLR(n,p) \
44 ((p)->bits[(n)/PERL_NFDBITS] &= ~((unsigned)1 << ((n)%PERL_NFDBITS)))
45
46#define PERL_FD_SET(n,p) \
47 ((p)->bits[(n)/PERL_NFDBITS] |= ((unsigned)1 << ((n)%PERL_NFDBITS)))
48
49#define PERL_FD_ZERO(p) memset((char *)(p),0,sizeof(*(p)))
50
51#define PERL_FD_ISSET(n,p) \
52 ((p)->bits[(n)/PERL_NFDBITS] & ((unsigned)1 << ((n)%PERL_NFDBITS)))
53
54#else /* USE_SOCKETS_AS_HANDLES */
55
56#define Perl_fd_set fd_set
57#define PERL_FD_SET(n,p) FD_SET(n,p)
58#define PERL_FD_CLR(n,p) FD_CLR(n,p)
59#define PERL_FD_ISSET(n,p) FD_ISSET(n,p)
60#define PERL_FD_ZERO(p) FD_ZERO(p)
61
62#endif /* USE_SOCKETS_AS_HANDLES */
63
64SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
65int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen);
66int win32_closesocket (SOCKET s);
67int win32_connect (SOCKET s, const struct sockaddr *name, int namelen);
68int win32_ioctlsocket (SOCKET s, long cmd, u_long *argp);
69int win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen);
70int win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen);
71int win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
72u_long win32_htonl (u_long hostlong);
73u_short win32_htons (u_short hostshort);
74unsigned long win32_inet_addr (const char * cp);
75char * win32_inet_ntoa (struct in_addr in);
76int win32_listen (SOCKET s, int backlog);
77u_long win32_ntohl (u_long netlong);
78u_short win32_ntohs (u_short netshort);
79int win32_recv (SOCKET s, char * buf, int len, int flags);
80int win32_recvfrom (SOCKET s, char * buf, int len, int flags,
81 struct sockaddr *from, int * fromlen);
82int win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds,
83 const struct timeval *timeout);
84int win32_send (SOCKET s, const char * buf, int len, int flags);
85int win32_sendto (SOCKET s, const char * buf, int len, int flags,
86 const struct sockaddr *to, int tolen);
87int win32_setsockopt (SOCKET s, int level, int optname,
88 const char * optval, int optlen);
89SOCKET win32_socket (int af, int type, int protocol);
90int win32_shutdown (SOCKET s, int how);
91
92/* Database function prototypes */
93
94struct hostent * win32_gethostbyaddr(const char * addr, int len, int type);
95struct hostent * win32_gethostbyname(const char * name);
96int win32_gethostname (char * name, int namelen);
97struct servent * win32_getservbyport(int port, const char * proto);
98struct servent * win32_getservbyname(const char * name, const char * proto);
99struct protoent * win32_getprotobynumber(int proto);
100struct protoent * win32_getprotobyname(const char * name);
101struct protoent *win32_getprotoent(void);
102struct servent *win32_getservent(void);
103void win32_sethostent(int stayopen);
104void win32_setnetent(int stayopen);
105struct netent * win32_getnetent(void);
106struct netent * win32_getnetbyname(char *name);
107struct netent * win32_getnetbyaddr(long net, int type);
108void win32_setprotoent(int stayopen);
109void win32_setservent(int stayopen);
110void win32_endhostent(void);
111void win32_endnetent(void);
112void win32_endprotoent(void);
113void win32_endservent(void);
114
115#ifndef WIN32SCK_IS_STDSCK
116
117/* direct to our version */
118
119#define htonl win32_htonl
120#define htons win32_htons
121#define ntohl win32_ntohl
122#define ntohs win32_ntohs
123#define inet_addr win32_inet_addr
124#define inet_ntoa win32_inet_ntoa
125
126#define socket win32_socket
127#define bind win32_bind
128#define listen win32_listen
129#define accept win32_accept
130#define connect win32_connect
131#define send win32_send
132#define sendto win32_sendto
133#define recv win32_recv
134#define recvfrom win32_recvfrom
135#define shutdown win32_shutdown
136#define closesocket win32_closesocket
137#define ioctlsocket win32_ioctlsocket
138#define setsockopt win32_setsockopt
139#define getsockopt win32_getsockopt
140#define getpeername win32_getpeername
141#define getsockname win32_getsockname
142#define gethostname win32_gethostname
143#define gethostbyname win32_gethostbyname
144#define gethostbyaddr win32_gethostbyaddr
145#define getprotobyname win32_getprotobyname
146#define getprotobynumber win32_getprotobynumber
147#define getservbyname win32_getservbyname
148#define getservbyport win32_getservbyport
149#define select win32_select
150#define endhostent win32_endhostent
151#define endnetent win32_endnetent
152#define endprotoent win32_endprotoent
153#define endservent win32_endservent
154#define getnetent win32_getnetent
155#define getnetbyname win32_getnetbyname
156#define getnetbyaddr win32_getnetbyaddr
157#define getprotoent win32_getprotoent
158#define getservent win32_getservent
159#define sethostent win32_sethostent
160#define setnetent win32_setnetent
161#define setprotoent win32_setprotoent
162#define setservent win32_setservent
163
164#ifdef USE_SOCKETS_AS_HANDLES
165#undef fd_set
166#undef FD_SET
167#undef FD_CLR
168#undef FD_ISSET
169#undef FD_ZERO
170#define fd_set Perl_fd_set
171#define FD_SET(n,p) PERL_FD_SET(n,p)
172#define FD_CLR(n,p) PERL_FD_CLR(n,p)
173#define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
174#define FD_ZERO(p) PERL_FD_ZERO(p)
175#endif /* USE_SOCKETS_AS_HANDLES */
176
177#endif /* WIN32SCK_IS_STDSCK */
178
179#ifdef __cplusplus
180}
181#endif
182
183#endif /* _INC_SYS_SOCKET */
Note: See TracBrowser for help on using the repository browser.