Split the double-inclusion guard. Fixes a problem with #include_next.
[pspp] / lib / sys_socket_.h
1 /* Provide a sys/socket header file for systems lacking it (read: MinGW).
2    Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
3    Written by Simon Josefsson.
4
5    This program 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    This program 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 this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 /* This file is supposed to be used on platforms that lack <sys/socket.h>
20    and on platforms where <sys/socket.h> cannot be included standalone.
21    It is intended to provide definitions and prototypes needed by an
22    application.  */
23
24 #ifndef _GL_SYS_SOCKET_H
25
26 #if @HAVE_SYS_SOCKET_H@
27
28 /* On many platforms, <sys/socket.h> assumes prior inclusion of
29    <sys/types.h>.  */
30 # include <sys/types.h>
31
32 /* The include_next requires a split double-inclusion guard.  */
33 # if @HAVE_INCLUDE_NEXT@
34 #  include_next <sys/socket.h>
35 # else
36 #  include @ABSOLUTE_SYS_SOCKET_H@
37 # endif
38
39 #endif
40
41 #ifndef _GL_SYS_SOCKET_H
42 #define _GL_SYS_SOCKET_H
43
44 #if !@HAVE_SYS_SOCKET_H@
45
46 /* A platform that lacks <sys/socket.h>.
47
48    Currently only MinGW is supported.  See the gnulib manual regarding
49    Windows sockets.  MinGW has the header files winsock2.h and
50    ws2tcpip.h that declare the sys/socket.h definitions we need.  Note
51    that you can influence which definitions you get by setting the
52    WINVER symbol before including these two files.  For example,
53    getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
54    symbol is set indiriectly through WINVER).  You can set this by
55    adding AC_DEFINE(WINVER, 0x0501) to configure.ac.  Note that your
56    code may not run on older Windows releases then.  My Windows 2000
57    box was not able to run the code, for example.  The situation is
58    slightly confusing because:
59    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
60    suggests that getaddrinfo should be available on all Windows
61    releases. */
62
63
64 # if @HAVE_WINSOCK2_H@
65 #  include <winsock2.h>
66 # endif
67 # if @HAVE_WS2TCPIP_H@
68 #  include <ws2tcpip.h>
69 # endif
70
71 /* For shutdown(). */
72 # if !defined SHUT_RD && defined SD_RECEIVE
73 #  define SHUT_RD SD_RECEIVE
74 # endif
75 # if !defined SHUT_WR && defined SD_SEND
76 #  define SHUT_WR SD_SEND
77 # endif
78 # if !defined SHUT_RDWR && defined SD_BOTH
79 #  define SHUT_RDWR SD_BOTH
80 # endif
81
82 # if defined _WIN32 || defined __WIN32__
83 #  define ENOTSOCK                WSAENOTSOCK
84 #  define EADDRINUSE              WSAEADDRINUSE
85 #  define ENETRESET               WSAENETRESET
86 #  define ECONNABORTED            WSAECONNABORTED
87 #  define ECONNRESET              WSAECONNRESET
88 #  define ENOTCONN                WSAENOTCONN
89 #  define ESHUTDOWN               WSAESHUTDOWN
90 # endif
91
92 #endif /* HAVE_SYS_SOCKET_H */
93
94 #endif /* _GL_SYS_SOCKET_H */
95 #endif /* _GL_SYS_SOCKET_H */