Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1 | #ifndef HEADER_CURL_SETUP_H |
| 2 | #define HEADER_CURL_SETUP_H |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 10 | * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 11 | * |
| 12 | * This software is licensed as described in the file COPYING, which |
| 13 | * you should have received as part of this distribution. The terms |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 14 | * are also available at https://curl.haxx.se/docs/copyright.html. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 15 | * |
| 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 17 | * copies of the Software, and permit persons to whom the Software is |
| 18 | * furnished to do so, under the terms of the COPYING file. |
| 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | /* |
| 26 | * Define WIN32 when build target is Win32 API |
| 27 | */ |
| 28 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 29 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \ |
| 30 | !defined(__SYMBIAN32__) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 31 | #define WIN32 |
| 32 | #endif |
| 33 | |
| 34 | /* |
| 35 | * Include configuration script results or hand-crafted |
| 36 | * configuration file for platforms which lack config tool. |
| 37 | */ |
| 38 | |
| 39 | #ifdef HAVE_CONFIG_H |
| 40 | |
| 41 | #include "curl_config.h" |
| 42 | |
| 43 | #else /* HAVE_CONFIG_H */ |
| 44 | |
| 45 | #ifdef _WIN32_WCE |
| 46 | # include "config-win32ce.h" |
| 47 | #else |
| 48 | # ifdef WIN32 |
| 49 | # include "config-win32.h" |
| 50 | # endif |
| 51 | #endif |
| 52 | |
| 53 | #if defined(macintosh) && defined(__MRC__) |
| 54 | # include "config-mac.h" |
| 55 | #endif |
| 56 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 57 | #ifdef __riscos__ |
| 58 | # include "config-riscos.h" |
| 59 | #endif |
| 60 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 61 | #ifdef __AMIGA__ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 62 | # include "config-amigaos.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 63 | #endif |
| 64 | |
| 65 | #ifdef __SYMBIAN32__ |
| 66 | # include "config-symbian.h" |
| 67 | #endif |
| 68 | |
| 69 | #ifdef __OS400__ |
| 70 | # include "config-os400.h" |
| 71 | #endif |
| 72 | |
| 73 | #ifdef TPF |
| 74 | # include "config-tpf.h" |
| 75 | #endif |
| 76 | |
| 77 | #ifdef __VXWORKS__ |
| 78 | # include "config-vxworks.h" |
| 79 | #endif |
| 80 | |
| 81 | #endif /* HAVE_CONFIG_H */ |
| 82 | |
| 83 | /* ================================================================ */ |
| 84 | /* Definition of preprocessor macros/symbols which modify compiler */ |
| 85 | /* behavior or generated code characteristics must be done here, */ |
| 86 | /* as appropriate, before any system header file is included. It is */ |
| 87 | /* also possible to have them defined in the config file included */ |
| 88 | /* before this point. As a result of all this we frown inclusion of */ |
| 89 | /* system header files in our config files, avoid this at any cost. */ |
| 90 | /* ================================================================ */ |
| 91 | |
| 92 | /* |
| 93 | * AIX 4.3 and newer needs _THREAD_SAFE defined to build |
| 94 | * proper reentrant code. Others may also need it. |
| 95 | */ |
| 96 | |
| 97 | #ifdef NEED_THREAD_SAFE |
| 98 | # ifndef _THREAD_SAFE |
| 99 | # define _THREAD_SAFE |
| 100 | # endif |
| 101 | #endif |
| 102 | |
| 103 | /* |
| 104 | * Tru64 needs _REENTRANT set for a few function prototypes and |
| 105 | * things to appear in the system header files. Unixware needs it |
| 106 | * to build proper reentrant code. Others may also need it. |
| 107 | */ |
| 108 | |
| 109 | #ifdef NEED_REENTRANT |
| 110 | # ifndef _REENTRANT |
| 111 | # define _REENTRANT |
| 112 | # endif |
| 113 | #endif |
| 114 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 115 | /* Solaris needs this to get a POSIX-conformant getpwuid_r */ |
| 116 | #if defined(sun) || defined(__sun) |
| 117 | # ifndef _POSIX_PTHREAD_SEMANTICS |
| 118 | # define _POSIX_PTHREAD_SEMANTICS 1 |
| 119 | # endif |
| 120 | #endif |
| 121 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 122 | /* ================================================================ */ |
| 123 | /* If you need to include a system header file for your platform, */ |
| 124 | /* please, do it beyond the point further indicated in this file. */ |
| 125 | /* ================================================================ */ |
| 126 | |
| 127 | /* |
| 128 | * libcurl's external interface definitions are also used internally, |
| 129 | * and might also include required system header files to define them. |
| 130 | */ |
| 131 | |
| 132 | #include <curl/curlbuild.h> |
| 133 | |
| 134 | /* |
| 135 | * Compile time sanity checks must also be done when building the library. |
| 136 | */ |
| 137 | |
| 138 | #include <curl/curlrules.h> |
| 139 | |
| 140 | /* |
| 141 | * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro |
| 142 | */ |
| 143 | |
| 144 | #ifdef SIZEOF_CURL_OFF_T |
| 145 | # error "SIZEOF_CURL_OFF_T shall not be defined!" |
| 146 | Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined |
| 147 | #endif |
| 148 | |
| 149 | /* |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 150 | * Disable other protocols when http is the only one desired. |
| 151 | */ |
| 152 | |
| 153 | #ifdef HTTP_ONLY |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 154 | # ifndef CURL_DISABLE_TFTP |
| 155 | # define CURL_DISABLE_TFTP |
| 156 | # endif |
| 157 | # ifndef CURL_DISABLE_FTP |
| 158 | # define CURL_DISABLE_FTP |
| 159 | # endif |
| 160 | # ifndef CURL_DISABLE_LDAP |
| 161 | # define CURL_DISABLE_LDAP |
| 162 | # endif |
| 163 | # ifndef CURL_DISABLE_TELNET |
| 164 | # define CURL_DISABLE_TELNET |
| 165 | # endif |
| 166 | # ifndef CURL_DISABLE_DICT |
| 167 | # define CURL_DISABLE_DICT |
| 168 | # endif |
| 169 | # ifndef CURL_DISABLE_FILE |
| 170 | # define CURL_DISABLE_FILE |
| 171 | # endif |
| 172 | # ifndef CURL_DISABLE_RTSP |
| 173 | # define CURL_DISABLE_RTSP |
| 174 | # endif |
| 175 | # ifndef CURL_DISABLE_POP3 |
| 176 | # define CURL_DISABLE_POP3 |
| 177 | # endif |
| 178 | # ifndef CURL_DISABLE_IMAP |
| 179 | # define CURL_DISABLE_IMAP |
| 180 | # endif |
| 181 | # ifndef CURL_DISABLE_SMTP |
| 182 | # define CURL_DISABLE_SMTP |
| 183 | # endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 184 | # ifndef CURL_DISABLE_RTMP |
| 185 | # define CURL_DISABLE_RTMP |
| 186 | # endif |
| 187 | # ifndef CURL_DISABLE_GOPHER |
| 188 | # define CURL_DISABLE_GOPHER |
| 189 | # endif |
| 190 | # ifndef CURL_DISABLE_SMB |
| 191 | # define CURL_DISABLE_SMB |
| 192 | # endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 193 | #endif |
| 194 | |
| 195 | /* |
| 196 | * When http is disabled rtsp is not supported. |
| 197 | */ |
| 198 | |
| 199 | #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP) |
| 200 | # define CURL_DISABLE_RTSP |
| 201 | #endif |
| 202 | |
| 203 | /* ================================================================ */ |
| 204 | /* No system header file shall be included in this file before this */ |
| 205 | /* point. The only allowed ones are those included from curlbuild.h */ |
| 206 | /* ================================================================ */ |
| 207 | |
| 208 | /* |
| 209 | * OS/400 setup file includes some system headers. |
| 210 | */ |
| 211 | |
| 212 | #ifdef __OS400__ |
| 213 | # include "setup-os400.h" |
| 214 | #endif |
| 215 | |
| 216 | /* |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 217 | * VMS setup file includes some system headers. |
| 218 | */ |
| 219 | |
| 220 | #ifdef __VMS |
| 221 | # include "setup-vms.h" |
| 222 | #endif |
| 223 | |
| 224 | /* |
Alex Deymo | e3149cc | 2016-10-05 11:18:42 -0700 | [diff] [blame] | 225 | * Use getaddrinfo to resolve the IPv4 address literal. If the current network |
| 226 | * interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64, |
| 227 | * performing this task will result in a synthesized IPv6 address. |
| 228 | */ |
| 229 | #ifdef __APPLE__ |
| 230 | #define USE_RESOLVE_ON_IPS 1 |
| 231 | #endif |
| 232 | |
| 233 | /* |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 234 | * Include header files for windows builds before redefining anything. |
| 235 | * Use this preprocessor block only to include or exclude windows.h, |
| 236 | * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs |
| 237 | * to any other further and independent block. Under Cygwin things work |
| 238 | * just as under linux (e.g. <sys/socket.h>) and the winsock headers should |
| 239 | * never be included when __CYGWIN__ is defined. configure script takes |
| 240 | * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, |
| 241 | * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. |
| 242 | */ |
| 243 | |
| 244 | #ifdef HAVE_WINDOWS_H |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 245 | # if defined(UNICODE) && !defined(_UNICODE) |
| 246 | # define _UNICODE |
| 247 | # endif |
| 248 | # if defined(_UNICODE) && !defined(UNICODE) |
| 249 | # define UNICODE |
| 250 | # endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 251 | # ifndef WIN32_LEAN_AND_MEAN |
| 252 | # define WIN32_LEAN_AND_MEAN |
| 253 | # endif |
| 254 | # include <windows.h> |
| 255 | # ifdef HAVE_WINSOCK2_H |
| 256 | # include <winsock2.h> |
| 257 | # ifdef HAVE_WS2TCPIP_H |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 258 | # include <ws2tcpip.h> |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 259 | # endif |
| 260 | # else |
| 261 | # ifdef HAVE_WINSOCK_H |
| 262 | # include <winsock.h> |
| 263 | # endif |
| 264 | # endif |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 265 | # include <tchar.h> |
| 266 | # ifdef UNICODE |
| 267 | typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str); |
| 268 | # endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 269 | #endif |
| 270 | |
| 271 | /* |
| 272 | * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else |
| 273 | * define USE_WINSOCK to 1 if we have and use WINSOCK API, else |
| 274 | * undefine USE_WINSOCK. |
| 275 | */ |
| 276 | |
| 277 | #undef USE_WINSOCK |
| 278 | |
| 279 | #ifdef HAVE_WINSOCK2_H |
| 280 | # define USE_WINSOCK 2 |
| 281 | #else |
| 282 | # ifdef HAVE_WINSOCK_H |
| 283 | # define USE_WINSOCK 1 |
| 284 | # endif |
| 285 | #endif |
| 286 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 287 | #ifdef USE_LWIPSOCK |
| 288 | # include <lwip/init.h> |
| 289 | # include <lwip/sockets.h> |
| 290 | # include <lwip/netdb.h> |
| 291 | #endif |
| 292 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 293 | #ifdef HAVE_EXTRA_STRICMP_H |
| 294 | # include <extra/stricmp.h> |
| 295 | #endif |
| 296 | |
| 297 | #ifdef HAVE_EXTRA_STRDUP_H |
| 298 | # include <extra/strdup.h> |
| 299 | #endif |
| 300 | |
| 301 | #ifdef TPF |
| 302 | # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */ |
| 303 | # include <string.h> /* for strcpy and strlen */ |
| 304 | # include <stdlib.h> /* for rand and srand */ |
| 305 | # include <sys/socket.h> /* for select and ioctl*/ |
| 306 | # include <netdb.h> /* for in_addr_t definition */ |
| 307 | # include <tpf/sysapi.h> /* for tpf_process_signals */ |
| 308 | /* change which select is used for libcurl */ |
| 309 | # define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e) |
| 310 | #endif |
| 311 | |
| 312 | #ifdef __VXWORKS__ |
| 313 | # include <sockLib.h> /* for generic BSD socket functions */ |
| 314 | # include <ioLib.h> /* for basic I/O interface functions */ |
| 315 | #endif |
| 316 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 317 | #ifdef __AMIGA__ |
| 318 | # ifndef __ixemul__ |
| 319 | # include <exec/types.h> |
| 320 | # include <exec/execbase.h> |
| 321 | # include <proto/exec.h> |
| 322 | # include <proto/dos.h> |
| 323 | # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0) |
| 324 | # endif |
| 325 | #endif |
| 326 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 327 | #include <stdio.h> |
| 328 | #ifdef HAVE_ASSERT_H |
| 329 | #include <assert.h> |
| 330 | #endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 331 | |
| 332 | #ifdef __TANDEM /* for nsr-tandem-nsk systems */ |
| 333 | #include <floss.h> |
| 334 | #endif |
| 335 | |
| 336 | #ifndef STDC_HEADERS /* no standard C headers! */ |
| 337 | #include <curl/stdcheaders.h> |
| 338 | #endif |
| 339 | |
| 340 | #ifdef __POCC__ |
| 341 | # include <sys/types.h> |
| 342 | # include <unistd.h> |
| 343 | # define sys_nerr EILSEQ |
| 344 | #endif |
| 345 | |
| 346 | /* |
| 347 | * Salford-C kludge section (mostly borrowed from wxWidgets). |
| 348 | */ |
| 349 | #ifdef __SALFORDC__ |
| 350 | #pragma suppress 353 /* Possible nested comments */ |
| 351 | #pragma suppress 593 /* Define not used */ |
| 352 | #pragma suppress 61 /* enum has no name */ |
| 353 | #pragma suppress 106 /* unnamed, unused parameter */ |
| 354 | #include <clib.h> |
| 355 | #endif |
| 356 | |
| 357 | /* |
| 358 | * Large file (>2Gb) support using WIN32 functions. |
| 359 | */ |
| 360 | |
| 361 | #ifdef USE_WIN32_LARGE_FILES |
| 362 | # include <io.h> |
| 363 | # include <sys/types.h> |
| 364 | # include <sys/stat.h> |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 365 | # undef lseek |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 366 | # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 367 | # undef fstat |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 368 | # define fstat(fdes,stp) _fstati64(fdes, stp) |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 369 | # undef stat |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 370 | # define stat(fname,stp) _stati64(fname, stp) |
| 371 | # define struct_stat struct _stati64 |
| 372 | # define LSEEK_ERROR (__int64)-1 |
| 373 | #endif |
| 374 | |
| 375 | /* |
| 376 | * Small file (<2Gb) support using WIN32 functions. |
| 377 | */ |
| 378 | |
| 379 | #ifdef USE_WIN32_SMALL_FILES |
| 380 | # include <io.h> |
| 381 | # include <sys/types.h> |
| 382 | # include <sys/stat.h> |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 383 | # ifndef _WIN32_WCE |
| 384 | # undef lseek |
| 385 | # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence) |
| 386 | # define fstat(fdes,stp) _fstat(fdes, stp) |
| 387 | # define stat(fname,stp) _stat(fname, stp) |
| 388 | # define struct_stat struct _stat |
| 389 | # endif |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 390 | # define LSEEK_ERROR (long)-1 |
| 391 | #endif |
| 392 | |
| 393 | #ifndef struct_stat |
| 394 | # define struct_stat struct stat |
| 395 | #endif |
| 396 | |
| 397 | #ifndef LSEEK_ERROR |
| 398 | # define LSEEK_ERROR (off_t)-1 |
| 399 | #endif |
| 400 | |
| 401 | /* |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 402 | * Arg 2 type for gethostname in case it hasn't been defined in config file. |
| 403 | */ |
| 404 | |
| 405 | #ifndef GETHOSTNAME_TYPE_ARG2 |
| 406 | # ifdef USE_WINSOCK |
| 407 | # define GETHOSTNAME_TYPE_ARG2 int |
| 408 | # else |
| 409 | # define GETHOSTNAME_TYPE_ARG2 size_t |
| 410 | # endif |
| 411 | #endif |
| 412 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 413 | /* Below we define some functions. They should |
| 414 | |
| 415 | 4. set the SIGALRM signal timeout |
| 416 | 5. set dir/file naming defines |
| 417 | */ |
| 418 | |
| 419 | #ifdef WIN32 |
| 420 | |
| 421 | # define DIR_CHAR "\\" |
| 422 | # define DOT_CHAR "_" |
| 423 | |
| 424 | #else /* WIN32 */ |
| 425 | |
| 426 | # ifdef MSDOS /* Watt-32 */ |
| 427 | |
| 428 | # include <sys/ioctl.h> |
| 429 | # define select(n,r,w,x,t) select_s(n,r,w,x,t) |
| 430 | # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) |
| 431 | # include <tcp.h> |
| 432 | # ifdef word |
| 433 | # undef word |
| 434 | # endif |
| 435 | # ifdef byte |
| 436 | # undef byte |
| 437 | # endif |
| 438 | |
| 439 | # endif /* MSDOS */ |
| 440 | |
| 441 | # ifdef __minix |
| 442 | /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */ |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 443 | extern char *strtok_r(char *s, const char *delim, char **last); |
| 444 | extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 445 | # endif |
| 446 | |
| 447 | # define DIR_CHAR "/" |
| 448 | # ifndef DOT_CHAR |
| 449 | # define DOT_CHAR "." |
| 450 | # endif |
| 451 | |
| 452 | # ifdef MSDOS |
| 453 | # undef DOT_CHAR |
| 454 | # define DOT_CHAR "_" |
| 455 | # endif |
| 456 | |
| 457 | # ifndef fileno /* sunos 4 have this as a macro! */ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 458 | int fileno(FILE *stream); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 459 | # endif |
| 460 | |
| 461 | #endif /* WIN32 */ |
| 462 | |
| 463 | /* |
| 464 | * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN |
| 465 | * defined in ws2tcpip.h as well as to provide IPv6 support. |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 466 | * Does not apply if lwIP is used. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 467 | */ |
| 468 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 469 | #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 470 | # if !defined(HAVE_WS2TCPIP_H) || \ |
| 471 | ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN)) |
| 472 | # undef HAVE_GETADDRINFO_THREADSAFE |
| 473 | # undef HAVE_FREEADDRINFO |
| 474 | # undef HAVE_GETADDRINFO |
| 475 | # undef HAVE_GETNAMEINFO |
| 476 | # undef ENABLE_IPV6 |
| 477 | # endif |
| 478 | #endif |
| 479 | |
| 480 | /* ---------------------------------------------------------------- */ |
| 481 | /* resolver specialty compile-time defines */ |
| 482 | /* CURLRES_* defines to use in the host*.c sources */ |
| 483 | /* ---------------------------------------------------------------- */ |
| 484 | |
| 485 | /* |
| 486 | * lcc-win32 doesn't have _beginthreadex(), lacks threads support. |
| 487 | */ |
| 488 | |
| 489 | #if defined(__LCC__) && defined(WIN32) |
| 490 | # undef USE_THREADS_POSIX |
| 491 | # undef USE_THREADS_WIN32 |
| 492 | #endif |
| 493 | |
| 494 | /* |
| 495 | * MSVC threads support requires a multi-threaded runtime library. |
| 496 | * _beginthreadex() is not available in single-threaded ones. |
| 497 | */ |
| 498 | |
| 499 | #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT) |
| 500 | # undef USE_THREADS_POSIX |
| 501 | # undef USE_THREADS_WIN32 |
| 502 | #endif |
| 503 | |
| 504 | /* |
| 505 | * Mutually exclusive CURLRES_* definitions. |
| 506 | */ |
| 507 | |
| 508 | #ifdef USE_ARES |
| 509 | # define CURLRES_ASYNCH |
| 510 | # define CURLRES_ARES |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 511 | /* now undef the stock libc functions just to avoid them being used */ |
| 512 | # undef HAVE_GETADDRINFO |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 513 | # undef HAVE_FREEADDRINFO |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 514 | # undef HAVE_GETHOSTBYNAME |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 515 | #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) |
| 516 | # define CURLRES_ASYNCH |
| 517 | # define CURLRES_THREADED |
| 518 | #else |
| 519 | # define CURLRES_SYNCH |
| 520 | #endif |
| 521 | |
| 522 | #ifdef ENABLE_IPV6 |
| 523 | # define CURLRES_IPV6 |
| 524 | #else |
| 525 | # define CURLRES_IPV4 |
| 526 | #endif |
| 527 | |
| 528 | /* ---------------------------------------------------------------- */ |
| 529 | |
| 530 | /* |
| 531 | * When using WINSOCK, TELNET protocol requires WINSOCK2 API. |
| 532 | */ |
| 533 | |
| 534 | #if defined(USE_WINSOCK) && (USE_WINSOCK != 2) |
| 535 | # define CURL_DISABLE_TELNET 1 |
| 536 | #endif |
| 537 | |
| 538 | /* |
| 539 | * msvc 6.0 does not have struct sockaddr_storage and |
| 540 | * does not define IPPROTO_ESP in winsock2.h. But both |
| 541 | * are available if PSDK is properly installed. |
| 542 | */ |
| 543 | |
| 544 | #if defined(_MSC_VER) && !defined(__POCC__) |
| 545 | # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP)) |
| 546 | # undef HAVE_STRUCT_SOCKADDR_STORAGE |
| 547 | # endif |
| 548 | #endif |
| 549 | |
| 550 | /* |
| 551 | * Intentionally fail to build when using msvc 6.0 without PSDK installed. |
| 552 | * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK |
| 553 | * in lib/config-win32.h although absolutely discouraged and unsupported. |
| 554 | */ |
| 555 | |
| 556 | #if defined(_MSC_VER) && !defined(__POCC__) |
| 557 | # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_)) |
| 558 | # if !defined(ALLOW_MSVC6_WITHOUT_PSDK) |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 559 | # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \ |
| 560 | "Windows Server 2003 PSDK" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 561 | # else |
| 562 | # define CURL_DISABLE_LDAP 1 |
| 563 | # endif |
| 564 | # endif |
| 565 | #endif |
| 566 | |
| 567 | #ifdef NETWARE |
| 568 | int netware_init(void); |
| 569 | #ifndef __NOVELL_LIBC__ |
| 570 | #include <sys/bsdskt.h> |
| 571 | #include <sys/timeval.h> |
| 572 | #endif |
| 573 | #endif |
| 574 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 575 | #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) |
| 576 | /* The lib and header are present */ |
| 577 | #define USE_LIBIDN2 |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 578 | #endif |
| 579 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 580 | #define LIBIDN_REQUIRED_VERSION "0.4.1" |
| 581 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 582 | #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \ |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 583 | defined(USE_POLARSSL) || defined(USE_AXTLS) || defined(USE_MBEDTLS) || \ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 584 | defined(USE_CYASSL) || defined(USE_SCHANNEL) || \ |
| 585 | defined(USE_DARWINSSL) || defined(USE_GSKIT) |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 586 | #define USE_SSL /* SSL support has been enabled */ |
| 587 | #endif |
| 588 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 589 | /* Single point where USE_SPNEGO definition might be defined */ |
| 590 | #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ |
| 591 | (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) |
| 592 | #define USE_SPNEGO |
| 593 | #endif |
| 594 | |
| 595 | /* Single point where USE_KERBEROS5 definition might be defined */ |
| 596 | #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \ |
| 597 | (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) |
| 598 | #define USE_KERBEROS5 |
| 599 | #endif |
| 600 | |
| 601 | /* Single point where USE_NTLM definition might be defined */ |
| 602 | #if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH) |
| 603 | #if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \ |
| 604 | defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \ |
| 605 | defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) |
| 606 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 607 | #define USE_NTLM |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 608 | |
| 609 | #elif defined(USE_MBEDTLS) |
| 610 | # include <mbedtls/md4.h> |
| 611 | # if defined(MBEDTLS_MD4_C) |
| 612 | #define USE_NTLM |
| 613 | # endif |
| 614 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 615 | #endif |
| 616 | #endif |
| 617 | |
| 618 | /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ |
| 619 | #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) |
| 620 | #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE") |
| 621 | #endif |
| 622 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 623 | /* |
| 624 | * Provide a mechanism to silence picky compilers, such as gcc 4.6+. |
| 625 | * Parameters should of course normally not be unused, but for example when |
| 626 | * we have multiple implementations of the same interface it may happen. |
| 627 | */ |
| 628 | |
| 629 | #if defined(__GNUC__) && ((__GNUC__ >= 3) || \ |
| 630 | ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7))) |
| 631 | # define UNUSED_PARAM __attribute__((__unused__)) |
| 632 | # define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 633 | #else |
| 634 | # define UNUSED_PARAM /*NOTHING*/ |
| 635 | # define WARN_UNUSED_RESULT |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 636 | #endif |
| 637 | |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 638 | /* |
| 639 | * Include macros and defines that should only be processed once. |
| 640 | */ |
| 641 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 642 | #ifndef HEADER_CURL_SETUP_ONCE_H |
| 643 | #include "curl_setup_once.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 644 | #endif |
| 645 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 646 | /* |
| 647 | * Definition of our NOP statement Object-like macro |
| 648 | */ |
| 649 | |
| 650 | #ifndef Curl_nop_stmt |
| 651 | # define Curl_nop_stmt do { } WHILE_FALSE |
| 652 | #endif |
| 653 | |
| 654 | /* |
| 655 | * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. |
| 656 | */ |
| 657 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 658 | #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H) |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 659 | # if defined(SOCKET) || \ |
| 660 | defined(USE_WINSOCK) || \ |
| 661 | defined(HAVE_WINSOCK_H) || \ |
| 662 | defined(HAVE_WINSOCK2_H) || \ |
| 663 | defined(HAVE_WS2TCPIP_H) |
| 664 | # error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" |
| 665 | # endif |
| 666 | #endif |
| 667 | |
| 668 | /* |
| 669 | * Portable symbolic names for Winsock shutdown() mode flags. |
| 670 | */ |
| 671 | |
| 672 | #ifdef USE_WINSOCK |
| 673 | # define SHUT_RD 0x00 |
| 674 | # define SHUT_WR 0x01 |
| 675 | # define SHUT_RDWR 0x02 |
| 676 | #endif |
| 677 | |
| 678 | /* Define S_ISREG if not defined by system headers, f.e. MSVC */ |
| 679 | #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) |
| 680 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 681 | #endif |
| 682 | |
| 683 | /* Define S_ISDIR if not defined by system headers, f.e. MSVC */ |
| 684 | #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) |
| 685 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
| 686 | #endif |
| 687 | |
| 688 | /* In Windows the default file mode is text but an application can override it. |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 689 | Therefore we specify it explicitly. https://github.com/curl/curl/pull/258 |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 690 | */ |
| 691 | #if defined(WIN32) || defined(MSDOS) |
| 692 | #define FOPEN_READTEXT "rt" |
| 693 | #define FOPEN_WRITETEXT "wt" |
| 694 | #elif defined(__CYGWIN__) |
| 695 | /* Cygwin has specific behavior we need to address when WIN32 is not defined. |
| 696 | https://cygwin.com/cygwin-ug-net/using-textbinary.html |
| 697 | For write we want our output to have line endings of LF and be compatible with |
| 698 | other Cygwin utilities. For read we want to handle input that may have line |
| 699 | endings either CRLF or LF so 't' is appropriate. |
| 700 | */ |
| 701 | #define FOPEN_READTEXT "rt" |
| 702 | #define FOPEN_WRITETEXT "w" |
| 703 | #else |
| 704 | #define FOPEN_READTEXT "r" |
| 705 | #define FOPEN_WRITETEXT "w" |
| 706 | #endif |
| 707 | |
Alex Deymo | d15eaac | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 708 | /* WinSock destroys recv() buffer when send() failed. |
| 709 | * Enabled automatically for Windows and for Cygwin as Cygwin sockets are |
| 710 | * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657 |
| 711 | * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround. |
| 712 | */ |
| 713 | #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND) |
| 714 | # if defined(WIN32) || defined(__CYGWIN__) |
| 715 | # define USE_RECV_BEFORE_SEND_WORKAROUND |
| 716 | # endif |
| 717 | #else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */ |
| 718 | # ifdef USE_RECV_BEFORE_SEND_WORKAROUND |
| 719 | # undef USE_RECV_BEFORE_SEND_WORKAROUND |
| 720 | # endif |
| 721 | #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */ |
| 722 | |
Elliott Hughes | cee0338 | 2017-06-23 12:17:18 -0700 | [diff] [blame] | 723 | /* Detect Windows App environment which has a restricted access |
| 724 | * to the Win32 APIs. */ |
| 725 | # if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602) |
| 726 | # include <winapifamily.h> |
| 727 | # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ |
| 728 | !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 729 | # define CURL_WINDOWS_APP |
| 730 | # endif |
| 731 | # endif |
| 732 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 733 | #endif /* HEADER_CURL_SETUP_H */ |