Mercurial > emacs
annotate nt/inc/sys/socket.h @ 79004:d771a0b43ed5
(follow-mode): Don't run hooks twice. Use `when'.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 08 Oct 2007 16:10:56 +0000 |
parents | 9d91cd80a431 |
children | 025766b01522 b98604865ea0 |
rev | line source |
---|---|
75245
2193e586660d
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68648
diff
changeset
|
1 /* Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, |
2193e586660d
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68648
diff
changeset
|
2 2006, 2007 Free Software Foundation, Inc. |
36375 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
78243
9d91cd80a431
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75245
diff
changeset
|
8 the Free Software Foundation; either version 3, or (at your option) |
36375 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
64083 | 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 Boston, MA 02110-1301, USA. */ | |
36375 | 20 |
21 | |
15139 | 22 /* Workable version of <sys/socket.h> based on winsock.h */ |
23 | |
24 #ifndef _SOCKET_H_ | |
25 #define _SOCKET_H_ | |
26 | |
27 /* defeat the multiple include protection */ | |
28 #ifdef _WINSOCKAPI_ | |
29 #undef _WINSOCKAPI_ | |
30 #endif | |
31091
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
31 #ifdef _WINSOCK_H |
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
32 #undef _WINSOCK_H |
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
33 #endif |
15139 | 34 |
35 /* avoid confusion with our version of select */ | |
36 #ifdef select | |
37 #undef select | |
38 #define MUST_REDEF_SELECT | |
39 #endif | |
40 | |
41 /* avoid clashing with our version of FD_SET if already defined */ | |
42 #ifdef FD_SET | |
43 #undef FD_SET | |
44 #undef FD_CLR | |
45 #undef FD_ISSET | |
46 #undef FD_ZERO | |
47 #endif | |
48 | |
49 /* avoid duplicate definition of timeval */ | |
50 #ifdef HAVE_TIMEVAL | |
51 #define timeval ws_timeval | |
52 #endif | |
53 | |
54 #include <winsock.h> | |
55 | |
56 /* redefine select to reference our version */ | |
57 #ifdef MUST_REDEF_SELECT | |
58 #define select sys_select | |
59 #undef MUST_REDEF_SELECT | |
60 #endif | |
61 | |
62 /* revert to our version of FD_SET */ | |
63 #undef FD_SET | |
64 #undef FD_CLR | |
65 #undef FD_ISSET | |
66 #undef FD_ZERO | |
31091
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
67 |
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
68 /* allow us to provide our own version of fd_set */ |
65f455b1ab20
(_WINSOCK_H): Undefine if defined.
Andrew Innes <andrewi@gnu.org>
parents:
18726
diff
changeset
|
69 #define fd_set ws_fd_set |
16594
bc3740dfe78c
Use new name w32.h for nt.h
Geoff Voelker <voelker@cs.washington.edu>
parents:
15139
diff
changeset
|
70 #include "w32.h" |
15139 | 71 |
72 #ifdef HAVE_TIMEVAL | |
73 #undef timeval | |
74 #endif | |
75 | |
76 /* shadow functions where we provide our own wrapper */ | |
77 #define socket sys_socket | |
78 #define bind sys_bind | |
79 #define connect sys_connect | |
80 #define htons sys_htons | |
81 #define ntohs sys_ntohs | |
82 #define inet_addr sys_inet_addr | |
83 #define gethostname sys_gethostname | |
84 #define gethostbyname sys_gethostbyname | |
45087
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
85 #define getpeername sys_getpeername |
15139 | 86 #define getservbyname sys_getservbyname |
18726
cfbf43d0fd54
(shutdown): Define.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16594
diff
changeset
|
87 #define shutdown sys_shutdown |
44040
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
88 #define setsockopt sys_setsockopt |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
89 #define listen sys_listen |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
90 #define getsockname sys_getsockname |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
91 #define accept sys_accept |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
92 #define recvfrom sys_recvfrom |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
93 #define sendto sys_sendto |
15139 | 94 |
95 int sys_socket(int af, int type, int protocol); | |
96 int sys_bind (int s, const struct sockaddr *addr, int namelen); | |
97 int sys_connect (int s, const struct sockaddr *addr, int namelen); | |
98 u_short sys_htons (u_short hostshort); | |
99 u_short sys_ntohs (u_short netshort); | |
100 unsigned long sys_inet_addr (const char * cp); | |
101 int sys_gethostname (char * name, int namelen); | |
45087
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
102 struct hostent * sys_gethostbyname (const char * name); |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
103 struct servent * sys_getservbyname (const char * name, const char * proto); |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
104 int sys_getpeername (int s, struct sockaddr *addr, int * namelen); |
18726
cfbf43d0fd54
(shutdown): Define.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16594
diff
changeset
|
105 int sys_shutdown (int socket, int how); |
63039
3b68a0c4a187
Change arg 4 of sys_setsockopt to `const void *',
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
106 int sys_setsockopt (int s, int level, int oname, const void * oval, int olen); |
44040
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
107 int sys_listen (int s, int backlog); |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
108 int sys_getsockname (int s, struct sockaddr * name, int * namelen); |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
109 int sys_accept (int s, struct sockaddr *addr, int *addrlen); |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
110 int sys_recvfrom (int s, char *buf, int len, int flags, |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
111 struct sockaddr *from, int * fromlen); |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
112 int sys_sendto (int s, const char * buf, int len, int flags, |
547d61a816e3
(sys_setsockopt, sys_listen, sys_getsockname)
Jason Rumney <jasonr@gnu.org>
parents:
36375
diff
changeset
|
113 const struct sockaddr *to, int tolen); |
15139 | 114 |
45087
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
115 /* In addition to wrappers for the winsock functions, we also provide |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
116 an fcntl function, for setting sockets to non-blocking mode. */ |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
117 int fcntl (int s, int cmd, int options); |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
118 #define F_SETFL 4 |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
119 #define O_NDELAY 04000 |
43b933182a40
(F_SETFL, O_NDELAY): Define.
Jason Rumney <jasonr@gnu.org>
parents:
44040
diff
changeset
|
120 |
15139 | 121 /* we are providing a real h_errno variable */ |
122 #undef h_errno | |
123 extern int h_errno; | |
124 | |
125 /* map winsock error codes to standard names */ | |
126 #define EWOULDBLOCK WSAEWOULDBLOCK | |
127 #define EINPROGRESS WSAEINPROGRESS | |
128 #define EALREADY WSAEALREADY | |
129 #define ENOTSOCK WSAENOTSOCK | |
130 #define EDESTADDRREQ WSAEDESTADDRREQ | |
131 #define EMSGSIZE WSAEMSGSIZE | |
132 #define EPROTOTYPE WSAEPROTOTYPE | |
133 #define ENOPROTOOPT WSAENOPROTOOPT | |
134 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT | |
135 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT | |
136 #define EOPNOTSUPP WSAEOPNOTSUPP | |
137 #define EPFNOSUPPORT WSAEPFNOSUPPORT | |
138 #define EAFNOSUPPORT WSAEAFNOSUPPORT | |
139 #define EADDRINUSE WSAEADDRINUSE | |
140 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL | |
141 #define ENETDOWN WSAENETDOWN | |
142 #define ENETUNREACH WSAENETUNREACH | |
143 #define ENETRESET WSAENETRESET | |
144 #define ECONNABORTED WSAECONNABORTED | |
145 #define ECONNRESET WSAECONNRESET | |
146 #define ENOBUFS WSAENOBUFS | |
147 #define EISCONN WSAEISCONN | |
148 #define ENOTCONN WSAENOTCONN | |
149 #define ESHUTDOWN WSAESHUTDOWN | |
150 #define ETOOMANYREFS WSAETOOMANYREFS | |
151 #define ETIMEDOUT WSAETIMEDOUT | |
152 #define ECONNREFUSED WSAECONNREFUSED | |
153 #define ELOOP WSAELOOP | |
154 /* #define ENAMETOOLONG WSAENAMETOOLONG */ | |
155 #define EHOSTDOWN WSAEHOSTDOWN | |
156 #define EHOSTUNREACH WSAEHOSTUNREACH | |
157 /* #define ENOTEMPTY WSAENOTEMPTY */ | |
158 #define EPROCLIM WSAEPROCLIM | |
159 #define EUSERS WSAEUSERS | |
160 #define EDQUOT WSAEDQUOT | |
161 #define ESTALE WSAESTALE | |
162 #define EREMOTE WSAEREMOTE | |
163 | |
164 #endif /* _SOCKET_H_ */ | |
165 | |
166 /* end of socket.h */ | |
52401 | 167 |
168 /* arch-tag: e3b8b91c-aaa0-4bc4-be57-a85a1dd247b4 | |
169 (do not change this comment) */ |