Merge from emacs--rel--22
[bpt/emacs.git] / nt / inc / sys / socket.h
index 5332617..f848231 100644 (file)
@@ -1,3 +1,24 @@
+/* Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005,
+      2006, 2007  Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+
 /* Workable version of <sys/socket.h> based on winsock.h */
 
 #ifndef _SOCKET_H_
@@ -7,6 +28,9 @@
 #ifdef _WINSOCKAPI_
 #undef _WINSOCKAPI_
 #endif
+#ifdef _WINSOCK_H
+#undef _WINSOCK_H
+#endif
 
 /* avoid confusion with our version of select */
 #ifdef select
 #undef FD_ZERO
 #endif
 
-/* allow us to provide our own version of fd_set */
-#define fd_set ws_fd_set
-
 /* avoid duplicate definition of timeval */
 #ifdef HAVE_TIMEVAL
 #define timeval ws_timeval
 #endif
 
-#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+/* process.c uses uint16_t (from C99) for IPv6, but
+   apparently it is not defined in some versions of mingw and msvc.  */
+#ifndef UINT16_C
+typedef unsigned short uint16_t;
+#endif
 
 /* redefine select to reference our version */
 #ifdef MUST_REDEF_SELECT
@@ -43,7 +70,9 @@
 #undef FD_CLR
 #undef FD_ISSET
 #undef FD_ZERO
-#undef fd_set
+
+/* allow us to provide our own version of fd_set */
+#define fd_set ws_fd_set
 #include "w32.h"
 
 #ifdef HAVE_TIMEVAL
 #define inet_addr      sys_inet_addr
 #define gethostname    sys_gethostname
 #define gethostbyname  sys_gethostbyname
+#define getpeername    sys_getpeername
 #define getservbyname  sys_getservbyname
 #define shutdown       sys_shutdown
+#define setsockopt     sys_setsockopt
+#define listen         sys_listen
+#define getsockname    sys_getsockname
+#define accept         sys_accept
+#define recvfrom       sys_recvfrom
+#define sendto         sys_sendto
 
 int sys_socket(int af, int type, int protocol);
 int sys_bind (int s, const struct sockaddr *addr, int namelen);
@@ -69,9 +105,24 @@ u_short sys_htons (u_short hostshort);
 u_short sys_ntohs (u_short netshort);
 unsigned long sys_inet_addr (const char * cp);
 int sys_gethostname (char * name, int namelen);
-struct hostent * sys_gethostbyname(const char * name);
-struct servent * sys_getservbyname(const char * name, const char * proto);
+struct hostent * sys_gethostbyname (const char * name);
+struct servent * sys_getservbyname (const char * name, const char * proto);
+int sys_getpeername (int s, struct sockaddr *addr, int * namelen);
 int sys_shutdown (int socket, int how);
+int sys_setsockopt (int s, int level, int oname, const void * oval, int olen);
+int sys_listen (int s, int backlog);
+int sys_getsockname (int s, struct sockaddr * name, int * namelen);
+int sys_accept (int s, struct sockaddr *addr, int *addrlen);
+int sys_recvfrom (int s, char *buf, int len, int flags,
+                 struct sockaddr *from, int * fromlen);
+int sys_sendto (int s, const char * buf, int len, int flags,
+               const struct sockaddr *to, int tolen);
+
+/* In addition to wrappers for the winsock functions, we also provide
+   an fcntl function, for setting sockets to non-blocking mode.  */
+int fcntl (int s, int cmd, int options);
+#define F_SETFL   4
+#define O_NDELAY  04000
 
 /* we are providing a real h_errno variable */
 #undef h_errno
@@ -119,3 +170,6 @@ extern int h_errno;
 #endif /* _SOCKET_H_ */
 
 /* end of socket.h */
+
+/* arch-tag: e3b8b91c-aaa0-4bc4-be57-a85a1dd247b4
+   (do not change this comment) */