36375
|
1 /* Copyright (C) 1995 Free Software Foundation, Inc.
|
|
2
|
|
3 This file is part of GNU Emacs.
|
|
4
|
|
5 GNU Emacs is free software; you can redistribute it and/or modify
|
|
6 it under the terms of the GNU General Public License as published by
|
|
7 the Free Software Foundation; either version 2, or (at your option)
|
|
8 any later version.
|
|
9
|
|
10 GNU Emacs is distributed in the hope that it will be useful,
|
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 GNU General Public License for more details.
|
|
14
|
|
15 You should have received a copy of the GNU General Public License
|
|
16 along with GNU Emacs; see the file COPYING. If not, write to
|
|
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
18 Boston, MA 02111-1307, USA. */
|
|
19
|
|
20
|
15139
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
21 /* Workable version of <sys/socket.h> based on winsock.h */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
22
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
23 #ifndef _SOCKET_H_
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
24 #define _SOCKET_H_
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
25
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
26 /* defeat the multiple include protection */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
27 #ifdef _WINSOCKAPI_
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
28 #undef _WINSOCKAPI_
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
29 #endif
|
31091
|
30 #ifdef _WINSOCK_H
|
|
31 #undef _WINSOCK_H
|
|
32 #endif
|
15139
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
33
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
34 /* avoid confusion with our version of select */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
35 #ifdef select
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
36 #undef select
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
37 #define MUST_REDEF_SELECT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
38 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
39
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
40 /* avoid clashing with our version of FD_SET if already defined */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
41 #ifdef FD_SET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
42 #undef FD_SET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
43 #undef FD_CLR
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
44 #undef FD_ISSET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
45 #undef FD_ZERO
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
46 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
47
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
48 /* avoid duplicate definition of timeval */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
49 #ifdef HAVE_TIMEVAL
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
50 #define timeval ws_timeval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
51 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
52
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
53 #include <winsock.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
54
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
55 /* redefine select to reference our version */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
56 #ifdef MUST_REDEF_SELECT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
57 #define select sys_select
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
58 #undef MUST_REDEF_SELECT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
59 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
60
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
61 /* revert to our version of FD_SET */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
62 #undef FD_SET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
63 #undef FD_CLR
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
64 #undef FD_ISSET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
65 #undef FD_ZERO
|
31091
|
66
|
|
67 /* allow us to provide our own version of fd_set */
|
|
68 #define fd_set ws_fd_set
|
16594
|
69 #include "w32.h"
|
15139
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
70
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
71 #ifdef HAVE_TIMEVAL
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
72 #undef timeval
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
73 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
74
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
75 /* shadow functions where we provide our own wrapper */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
76 #define socket sys_socket
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
77 #define bind sys_bind
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
78 #define connect sys_connect
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
79 #define htons sys_htons
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
80 #define ntohs sys_ntohs
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
81 #define inet_addr sys_inet_addr
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
82 #define gethostname sys_gethostname
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
83 #define gethostbyname sys_gethostbyname
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
84 #define getservbyname sys_getservbyname
|
18726
|
85 #define shutdown sys_shutdown
|
15139
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
86
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
87 int sys_socket(int af, int type, int protocol);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
88 int sys_bind (int s, const struct sockaddr *addr, int namelen);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
89 int sys_connect (int s, const struct sockaddr *addr, int namelen);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
90 u_short sys_htons (u_short hostshort);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
91 u_short sys_ntohs (u_short netshort);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
92 unsigned long sys_inet_addr (const char * cp);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
93 int sys_gethostname (char * name, int namelen);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
94 struct hostent * sys_gethostbyname(const char * name);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
95 struct servent * sys_getservbyname(const char * name, const char * proto);
|
18726
|
96 int sys_shutdown (int socket, int how);
|
15139
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
97
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
98 /* we are providing a real h_errno variable */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
99 #undef h_errno
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
100 extern int h_errno;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
101
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
102 /* map winsock error codes to standard names */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
103 #define EWOULDBLOCK WSAEWOULDBLOCK
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
104 #define EINPROGRESS WSAEINPROGRESS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
105 #define EALREADY WSAEALREADY
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
106 #define ENOTSOCK WSAENOTSOCK
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
107 #define EDESTADDRREQ WSAEDESTADDRREQ
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
108 #define EMSGSIZE WSAEMSGSIZE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
109 #define EPROTOTYPE WSAEPROTOTYPE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
110 #define ENOPROTOOPT WSAENOPROTOOPT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
111 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
112 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
113 #define EOPNOTSUPP WSAEOPNOTSUPP
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
114 #define EPFNOSUPPORT WSAEPFNOSUPPORT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
115 #define EAFNOSUPPORT WSAEAFNOSUPPORT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
116 #define EADDRINUSE WSAEADDRINUSE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
117 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
118 #define ENETDOWN WSAENETDOWN
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
119 #define ENETUNREACH WSAENETUNREACH
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
120 #define ENETRESET WSAENETRESET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
121 #define ECONNABORTED WSAECONNABORTED
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
122 #define ECONNRESET WSAECONNRESET
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
123 #define ENOBUFS WSAENOBUFS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
124 #define EISCONN WSAEISCONN
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
125 #define ENOTCONN WSAENOTCONN
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
126 #define ESHUTDOWN WSAESHUTDOWN
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
127 #define ETOOMANYREFS WSAETOOMANYREFS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
128 #define ETIMEDOUT WSAETIMEDOUT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
129 #define ECONNREFUSED WSAECONNREFUSED
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
130 #define ELOOP WSAELOOP
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
131 /* #define ENAMETOOLONG WSAENAMETOOLONG */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
132 #define EHOSTDOWN WSAEHOSTDOWN
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
133 #define EHOSTUNREACH WSAEHOSTUNREACH
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
134 /* #define ENOTEMPTY WSAENOTEMPTY */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
135 #define EPROCLIM WSAEPROCLIM
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
136 #define EUSERS WSAEUSERS
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
137 #define EDQUOT WSAEDQUOT
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
138 #define ESTALE WSAESTALE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
139 #define EREMOTE WSAEREMOTE
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
140
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
141 #endif /* _SOCKET_H_ */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
142
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
143 /* end of socket.h */
|