Replace MinGW with Windows to avoid ambiguities
[tinc] / src / have.h
1 #ifndef TINC_HAVE_H
2 #define TINC_HAVE_H
3
4 /*
5     have.h -- include headers which are known to exist
6     Copyright (C) 1998-2005 Ivo Timmermans
7                   2003-2021 Guus Sliepen <guus@tinc-vpn.org>
8
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License along
20     with this program; if not, write to the Free Software Foundation, Inc.,
21     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 #ifdef HAVE_WINDOWS
25 #define WINVER 0x0600
26 #define _WIN32_WINNT 0x0600
27 #define WIN32_LEAN_AND_MEAN
28 #define _CRT_SECURE_NO_WARNINGS
29 #define _CRT_NONSTDC_NO_WARNINGS
30 #endif
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <stdbool.h>
36 #include <string.h>
37 #include <ctype.h>
38 #include <signal.h>
39 #include <errno.h>
40 #include <fcntl.h>
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif
44 #include <limits.h>
45 #include <math.h>
46 #include <time.h>
47
48 #ifdef HAVE_ALLOCA_H
49 #include <alloca.h>
50 #elif defined(HAVE_NETBSD)
51 #define alloca(size) __builtin_alloca(size)
52 #endif
53
54 #ifdef HAVE_WINDOWS
55 #ifdef HAVE_W32API_H
56 #include <w32api.h>
57 #endif
58
59 #include <winsock2.h>
60 #include <windows.h>
61 #include <ws2tcpip.h>
62
63 #ifdef _MSC_VER
64 #include <io.h>
65 #include <process.h>
66 #include <direct.h>
67 #endif
68 #endif // HAVE_WINDOWS
69
70 #ifdef HAVE_TERMIOS_H
71 #include <termios.h>
72 #endif
73
74 #ifdef HAVE_INTTYPES_H
75 #include <inttypes.h>
76 #endif
77
78 /* Include system specific headers */
79
80 #ifdef HAVE_STDDEF_H
81 #include <stddef.h>
82 #endif
83
84 #ifdef HAVE_SYSLOG_H
85 #include <syslog.h>
86 #endif
87
88 #ifdef HAVE_SYS_TIME_H
89 #include <sys/time.h>
90 #endif
91
92
93 #ifdef HAVE_SYS_TYPES_H
94 #include <sys/types.h>
95 #endif
96
97 #ifdef HAVE_SYS_STAT_H
98 #include <sys/stat.h>
99 #endif
100
101 #ifdef HAVE_SYS_FILE_H
102 #include <sys/file.h>
103 #endif
104
105 #ifdef HAVE_SYS_MMAN_H
106 #include <sys/mman.h>
107 #endif
108
109 #ifdef HAVE_SYS_WAIT_H
110 #include <sys/wait.h>
111 #endif
112
113 #ifdef HAVE_SYS_IOCTL_H
114 #include <sys/ioctl.h>
115 #endif
116
117 #ifdef HAVE_SYS_PARAM_H
118 #include <sys/param.h>
119 #endif
120
121 #ifdef HAVE_SYS_RESOURCE_H
122 #include <sys/resource.h>
123 #endif
124
125 #ifdef HAVE_SYS_UN_H
126 #include <sys/un.h>
127 #endif
128
129 #ifdef HAVE_DIRENT_H
130 #include <dirent.h>
131 #elif defined(_MSC_VER)
132 #include "dirent.h"
133 #endif
134
135 /* SunOS really wants sys/socket.h BEFORE net/if.h,
136    and FreeBSD wants these lines below the rest. */
137
138 #ifdef HAVE_NETDB_H
139 #include <netdb.h>
140 #endif
141
142 #ifdef HAVE_SYS_SOCKET_H
143 #include <sys/socket.h>
144 #endif
145
146 #ifdef HAVE_NET_IF_H
147 #include <net/if.h>
148 #endif
149
150 #ifdef HAVE_NET_IF_TYPES_H
151 #include <net/if_types.h>
152 #endif
153
154 #ifdef HAVE_NET_IF_TUN_H
155 #include <net/if_tun.h>
156 #endif
157
158 #ifdef HAVE_NET_TUN_IF_TUN_H
159 #include <net/tun/if_tun.h>
160 #endif
161
162 #ifdef HAVE_NET_IF_TAP_H
163 #include <net/if_tap.h>
164 #endif
165
166 #ifdef HAVE_NET_TAP_IF_TAP_H
167 #include <net/tap/if_tap.h>
168 #endif
169
170 #ifdef HAVE_NETINET_IN_SYSTM_H
171 #include <netinet/in_systm.h>
172 #endif
173
174 #ifdef HAVE_NETINET_IN_H
175 #include <netinet/in.h>
176 #endif
177
178 #ifdef HAVE_ARPA_INET_H
179 #include <arpa/inet.h>
180 #endif
181
182 #ifdef HAVE_NETINET_IP_H
183 #include <netinet/ip.h>
184 #endif
185
186 #ifdef HAVE_NETINET_TCP_H
187 #include <netinet/tcp.h>
188 #endif
189
190 #ifdef HAVE_NETINET_IN6_H
191 #include <netinet/in6.h>
192 #endif
193
194 #ifdef HAVE_NETINET_IP6_H
195 #include <netinet/ip6.h>
196 #endif
197
198 #ifdef HAVE_NET_ETHERNET_H
199 #include <net/ethernet.h>
200 #endif
201
202 #ifdef HAVE_NET_IF_ARP_H
203 #include <net/if_arp.h>
204 #endif
205
206 #ifdef HAVE_NETINET_IP_ICMP_H
207 #include <netinet/ip_icmp.h>
208 #endif
209
210 #ifdef HAVE_NETINET_ICMP6_H
211 #include <netinet/icmp6.h>
212 #endif
213
214 #ifdef HAVE_NETINET_IF_ETHER_H
215 #include <netinet/if_ether.h>
216 #endif
217
218 #ifdef HAVE_ARPA_NAMESER_H
219 #include <arpa/nameser.h>
220 #endif
221
222 #ifdef HAVE_RESOLV_H
223 #include <resolv.h>
224 #endif
225
226 #ifdef HAVE_LINUX_IF_TUN_H
227 #include <linux/if_tun.h>
228 #endif
229
230 #ifdef HAVE_GETOPT_H
231 #include <getopt.h>
232 #else
233 #include "getopt.h"
234 #endif
235
236 #ifdef STATUS
237 #undef STATUS
238 #endif
239
240 #ifdef HAVE_WINDOWS
241 #define SLASH "\\"
242 #else
243 #define SLASH "/"
244 #endif
245
246 #endif