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