1 #ifndef HEADER_CURL_SETUP_H
2 #define HEADER_CURL_SETUP_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
26 * Define WIN32 when build target is Win32 API
29 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \
30 !defined(__SYMBIAN32__)
35 * Include configuration script results or hand-crafted
36 * configuration file for platforms which lack config tool.
41 #include "curl_config.h"
43 #else /* HAVE_CONFIG_H */
46 # include "config-win32ce.h"
49 # include "config-win32.h"
53 #if defined(macintosh) && defined(__MRC__)
54 # include "config-mac.h"
58 # include "config-riscos.h"
62 # include "config-amigaos.h"
66 # include "config-symbian.h"
70 # include "config-os400.h"
74 # include "config-tpf.h"
78 # include "config-vxworks.h"
81 #endif /* HAVE_CONFIG_H */
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 /* ================================================================ */
93 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
94 * proper reentrant code. Others may also need it.
97 #ifdef NEED_THREAD_SAFE
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.
109 #ifdef NEED_REENTRANT
115 /* ================================================================ */
116 /* If you need to include a system header file for your platform, */
117 /* please, do it beyond the point further indicated in this file. */
118 /* ================================================================ */
121 * libcurl's external interface definitions are also used internally,
122 * and might also include required system header files to define them.
125 #include <curl/curlbuild.h>
128 * Compile time sanity checks must also be done when building the library.
131 #include <curl/curlrules.h>
134 * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
137 #ifdef SIZEOF_CURL_OFF_T
138 # error "SIZEOF_CURL_OFF_T shall not be defined!"
139 Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
143 * Set up internal curl_off_t formatting string directives for
144 * exclusive use with libcurl's internal *printf functions.
148 # error "FORMAT_OFF_T shall not be defined before this point!"
149 Error Compilation_aborted_FORMAT_OFF_T_already_defined
153 # error "FORMAT_OFF_TU shall not be defined before this point!"
154 Error Compilation_aborted_FORMAT_OFF_TU_already_defined
157 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
158 # define FORMAT_OFF_T "lld"
159 # define FORMAT_OFF_TU "llu"
161 # define FORMAT_OFF_T "ld"
162 # define FORMAT_OFF_TU "lu"
166 * Disable other protocols when http is the only one desired.
170 # ifndef CURL_DISABLE_TFTP
171 # define CURL_DISABLE_TFTP
173 # ifndef CURL_DISABLE_FTP
174 # define CURL_DISABLE_FTP
176 # ifndef CURL_DISABLE_LDAP
177 # define CURL_DISABLE_LDAP
179 # ifndef CURL_DISABLE_TELNET
180 # define CURL_DISABLE_TELNET
182 # ifndef CURL_DISABLE_DICT
183 # define CURL_DISABLE_DICT
185 # ifndef CURL_DISABLE_FILE
186 # define CURL_DISABLE_FILE
188 # ifndef CURL_DISABLE_RTSP
189 # define CURL_DISABLE_RTSP
191 # ifndef CURL_DISABLE_POP3
192 # define CURL_DISABLE_POP3
194 # ifndef CURL_DISABLE_IMAP
195 # define CURL_DISABLE_IMAP
197 # ifndef CURL_DISABLE_SMTP
198 # define CURL_DISABLE_SMTP
200 # ifndef CURL_DISABLE_RTSP
201 # define CURL_DISABLE_RTSP
203 # ifndef CURL_DISABLE_RTMP
204 # define CURL_DISABLE_RTMP
206 # ifndef CURL_DISABLE_GOPHER
207 # define CURL_DISABLE_GOPHER
212 * When http is disabled rtsp is not supported.
215 #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
216 # define CURL_DISABLE_RTSP
219 /* ================================================================ */
220 /* No system header file shall be included in this file before this */
221 /* point. The only allowed ones are those included from curlbuild.h */
222 /* ================================================================ */
225 * OS/400 setup file includes some system headers.
229 # include "setup-os400.h"
233 * VMS setup file includes some system headers.
237 # include "setup-vms.h"
241 * Include header files for windows builds before redefining anything.
242 * Use this preprocessor block only to include or exclude windows.h,
243 * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
244 * to any other further and independent block. Under Cygwin things work
245 * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
246 * never be included when __CYGWIN__ is defined. configure script takes
247 * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
248 * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
251 #ifdef HAVE_WINDOWS_H
252 # if defined(UNICODE) && !defined(_UNICODE)
255 # if defined(_UNICODE) && !defined(UNICODE)
258 # ifndef WIN32_LEAN_AND_MEAN
259 # define WIN32_LEAN_AND_MEAN
261 # include <windows.h>
262 # ifdef HAVE_WINSOCK2_H
263 # include <winsock2.h>
264 # ifdef HAVE_WS2TCPIP_H
265 # include <ws2tcpip.h>
268 # ifdef HAVE_WINSOCK_H
269 # include <winsock.h>
273 typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str);
277 * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
278 * define USE_WINSOCK to 1 if we have and use WINSOCK API, else
279 * undefine USE_WINSOCK.
284 #ifdef HAVE_WINSOCK2_H
285 # define USE_WINSOCK 2
287 # ifdef HAVE_WINSOCK_H
288 # define USE_WINSOCK 1
293 # include <lwip/init.h>
294 # include <lwip/sockets.h>
295 # include <lwip/netdb.h>
298 #ifdef HAVE_EXTRA_STRICMP_H
299 # include <extra/stricmp.h>
302 #ifdef HAVE_EXTRA_STRDUP_H
303 # include <extra/strdup.h>
307 # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */
308 # include <string.h> /* for strcpy and strlen */
309 # include <stdlib.h> /* for rand and srand */
310 # include <sys/socket.h> /* for select and ioctl*/
311 # include <netdb.h> /* for in_addr_t definition */
312 # include <tpf/sysapi.h> /* for tpf_process_signals */
313 /* change which select is used for libcurl */
314 # define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
318 # include <sockLib.h> /* for generic BSD socket functions */
319 # include <ioLib.h> /* for basic I/O interface functions */
324 # include <exec/types.h>
325 # include <exec/execbase.h>
326 # include <proto/exec.h>
327 # include <proto/dos.h>
328 # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
337 #ifdef __TANDEM /* for nsr-tandem-nsk systems */
341 #ifndef STDC_HEADERS /* no standard C headers! */
342 #include <curl/stdcheaders.h>
346 # include <sys/types.h>
348 # define sys_nerr EILSEQ
352 * Salford-C kludge section (mostly borrowed from wxWidgets).
355 #pragma suppress 353 /* Possible nested comments */
356 #pragma suppress 593 /* Define not used */
357 #pragma suppress 61 /* enum has no name */
358 #pragma suppress 106 /* unnamed, unused parameter */
363 * Large file (>2Gb) support using WIN32 functions.
366 #ifdef USE_WIN32_LARGE_FILES
368 # include <sys/types.h>
369 # include <sys/stat.h>
371 # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
373 # define fstat(fdes,stp) _fstati64(fdes, stp)
375 # define stat(fname,stp) _stati64(fname, stp)
376 # define struct_stat struct _stati64
377 # define LSEEK_ERROR (__int64)-1
381 * Small file (<2Gb) support using WIN32 functions.
384 #ifdef USE_WIN32_SMALL_FILES
386 # include <sys/types.h>
387 # include <sys/stat.h>
390 # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
391 # define fstat(fdes,stp) _fstat(fdes, stp)
392 # define stat(fname,stp) _stat(fname, stp)
393 # define struct_stat struct _stat
395 # define LSEEK_ERROR (long)-1
399 # define struct_stat struct stat
403 # define LSEEK_ERROR (off_t)-1
407 * Default sizeof(off_t) in case it hasn't been defined in config file.
411 # if defined(__VMS) && !defined(__VAX)
412 # if defined(_LARGEFILE)
413 # define SIZEOF_OFF_T 8
415 # elif defined(__OS400__) && defined(__ILEC400__)
416 # if defined(_LARGE_FILES)
417 # define SIZEOF_OFF_T 8
419 # elif defined(__MVS__) && defined(__IBMC__)
420 # if defined(_LP64) || defined(_LARGE_FILES)
421 # define SIZEOF_OFF_T 8
423 # elif defined(__370__) && defined(__IBMC__)
424 # if defined(_LP64) || defined(_LARGE_FILES)
425 # define SIZEOF_OFF_T 8
428 # ifndef SIZEOF_OFF_T
429 # define SIZEOF_OFF_T 4
434 * Arg 2 type for gethostname in case it hasn't been defined in config file.
437 #ifndef GETHOSTNAME_TYPE_ARG2
439 # define GETHOSTNAME_TYPE_ARG2 int
441 # define GETHOSTNAME_TYPE_ARG2 size_t
445 /* Below we define some functions. They should
447 4. set the SIGALRM signal timeout
448 5. set dir/file naming defines
453 # define DIR_CHAR "\\"
454 # define DOT_CHAR "_"
458 # ifdef MSDOS /* Watt-32 */
460 # include <sys/ioctl.h>
461 # define select(n,r,w,x,t) select_s(n,r,w,x,t)
462 # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
474 /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
475 extern char * strtok_r(char *s, const char *delim, char **last);
476 extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
479 # define DIR_CHAR "/"
481 # define DOT_CHAR "."
486 # define DOT_CHAR "_"
489 # ifndef fileno /* sunos 4 have this as a macro! */
490 int fileno( FILE *stream);
496 * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
497 * defined in ws2tcpip.h as well as to provide IPv6 support.
500 #if defined(_MSC_VER) && !defined(__POCC__)
501 # if !defined(HAVE_WS2TCPIP_H) || \
502 ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
503 # undef HAVE_GETADDRINFO_THREADSAFE
504 # undef HAVE_FREEADDRINFO
505 # undef HAVE_GETADDRINFO
506 # undef HAVE_GETNAMEINFO
511 /* ---------------------------------------------------------------- */
512 /* resolver specialty compile-time defines */
513 /* CURLRES_* defines to use in the host*.c sources */
514 /* ---------------------------------------------------------------- */
517 * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
520 #if defined(__LCC__) && defined(WIN32)
521 # undef USE_THREADS_POSIX
522 # undef USE_THREADS_WIN32
526 * MSVC threads support requires a multi-threaded runtime library.
527 * _beginthreadex() is not available in single-threaded ones.
530 #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
531 # undef USE_THREADS_POSIX
532 # undef USE_THREADS_WIN32
536 * Mutually exclusive CURLRES_* definitions.
540 # define CURLRES_ASYNCH
541 # define CURLRES_ARES
542 /* now undef the stock libc functions just to avoid them being used */
543 # undef HAVE_GETADDRINFO
544 # undef HAVE_GETHOSTBYNAME
545 #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
546 # define CURLRES_ASYNCH
547 # define CURLRES_THREADED
549 # define CURLRES_SYNCH
553 # define CURLRES_IPV6
555 # define CURLRES_IPV4
558 /* ---------------------------------------------------------------- */
561 * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
564 #if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
565 # define CURL_DISABLE_TELNET 1
569 * msvc 6.0 does not have struct sockaddr_storage and
570 * does not define IPPROTO_ESP in winsock2.h. But both
571 * are available if PSDK is properly installed.
574 #if defined(_MSC_VER) && !defined(__POCC__)
575 # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
576 # undef HAVE_STRUCT_SOCKADDR_STORAGE
581 * Intentionally fail to build when using msvc 6.0 without PSDK installed.
582 * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
583 * in lib/config-win32.h although absolutely discouraged and unsupported.
586 #if defined(_MSC_VER) && !defined(__POCC__)
587 # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
588 # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
589 # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
590 "Windows Server 2003 PSDK"
592 # define CURL_DISABLE_LDAP 1
598 int netware_init(void);
599 #ifndef __NOVELL_LIBC__
600 #include <sys/bsdskt.h>
601 #include <sys/timeval.h>
605 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
606 /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
607 but we only work with libidn 0.4.1 or later) */
611 #ifndef SIZEOF_TIME_T
612 /* assume default size of time_t to be 32 bit */
613 #define SIZEOF_TIME_T 4
616 #define LIBIDN_REQUIRED_VERSION "0.4.1"
618 #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \
619 defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \
620 defined(USE_CYASSL) || defined(USE_SCHANNEL) || \
621 defined(USE_DARWINSSL) || defined(USE_GSKIT)
622 #define USE_SSL /* SSL support has been enabled */
625 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
626 #define USE_HTTP_NEGOTIATE
629 /* Single point where USE_NTLM definition might be done */
630 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
631 #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \
632 defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL)
637 /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
638 #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
639 #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
643 * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
644 * Parameters should of course normally not be unused, but for example when
645 * we have multiple implementations of the same interface it may happen.
648 #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
649 ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
650 # define UNUSED_PARAM __attribute__((__unused__))
652 # define UNUSED_PARAM /*NOTHING*/
656 * Include macros and defines that should only be processed once.
659 #ifndef HEADER_CURL_SETUP_ONCE_H
660 #include "curl_setup_once.h"
664 * Definition of our NOP statement Object-like macro
667 #ifndef Curl_nop_stmt
668 # define Curl_nop_stmt do { } WHILE_FALSE
672 * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
675 #if defined(__LWIP_OPT_H__)
676 # if defined(SOCKET) || \
677 defined(USE_WINSOCK) || \
678 defined(HAVE_WINSOCK_H) || \
679 defined(HAVE_WINSOCK2_H) || \
680 defined(HAVE_WS2TCPIP_H)
681 # error "Winsock and lwIP TCP/IP stack definitions shall not coexist!"
686 * Portable symbolic names for Winsock shutdown() mode flags.
690 # define SHUT_RD 0x00
691 # define SHUT_WR 0x01
692 # define SHUT_RDWR 0x02
695 /* Define S_ISREG if not defined by system headers, f.e. MSVC */
696 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
697 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
700 /* Define S_ISDIR if not defined by system headers, f.e. MSVC */
701 #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
702 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
705 #endif /* HEADER_CURL_SETUP_H */