Sync comment with reality.
[platform/upstream/c-ares.git] / setup.h
1 #ifndef __ARES_SETUP_H
2 #define __ARES_SETUP_H
3
4 /* $Id$ */
5
6 /* Copyright (C) 2004 - 2007 by Daniel Stenberg et al
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose and without fee is hereby granted, provided
10  * that the above copyright notice appear in all copies and that both that
11  * copyright notice and this permission notice appear in supporting
12  * documentation, and that the name of M.I.T. not be used in advertising or
13  * publicity pertaining to distribution of the software without specific,
14  * written prior permission.  M.I.T. makes no representations about the
15  * suitability of this software for any purpose.  It is provided "as is"
16  * without express or implied warranty.
17  */
18
19 /*
20  * Define WIN32 when build target is Win32 API
21  */
22
23 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
24 #define WIN32
25 #endif
26
27 /*
28  * Include configuration script results or hand-crafted
29  * configuration file for platforms which lack config tool.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #else
35
36 #ifdef WIN32
37 #include "config-win32.h"
38 #endif
39
40 #endif /* HAVE_CONFIG_H */
41
42 /*
43  * Tru64 needs _REENTRANT set for a few function prototypes and
44  * things to appear in the system header files. Unixware needs it
45  * to build proper reentrant code. Others may also need it.
46  */
47
48 #ifdef NEED_REENTRANT
49 #  ifndef _REENTRANT
50 #    define _REENTRANT
51 #  endif
52 #endif
53
54 /*
55  * Include header files for windows builds before redefining anything.
56  * Use this preproessor block only to include or exclude windows.h,
57  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
58  * to any other further and independant block.  Under Cygwin things work
59  * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
60  * never be included when __CYGWIN__ is defined.  configure script takes
61  * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
62  * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
63  */
64
65 #ifdef HAVE_WINDOWS_H
66 #  ifndef WIN32_LEAN_AND_MEAN
67 #    define WIN32_LEAN_AND_MEAN
68 #  endif
69 #  include <windows.h>
70 #  ifdef HAVE_WINSOCK2_H
71 #    include <winsock2.h>
72 #    ifdef HAVE_WS2TCPIP_H
73 #       include <ws2tcpip.h>
74 #    endif
75 #  else
76 #    ifdef HAVE_WINSOCK_H
77 #      include <winsock.h>
78 #    endif
79 #  endif
80 #endif
81
82 /*
83  * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
84  * define USE_WINSOCK to 1 if we have and use WINSOCK  API, else
85  * undefine USE_WINSOCK.
86  */
87
88 #undef USE_WINSOCK
89
90 #ifdef HAVE_WINSOCK2_H
91 #  define USE_WINSOCK 2
92 #else
93 #  ifdef HAVE_WINSOCK_H
94 #    define USE_WINSOCK 1
95 #  endif
96 #endif
97
98 /*
99  * Work-arounds for systems without configure support
100  */
101
102 #ifndef HAVE_CONFIG_H
103
104 #if defined(__DJGPP__) || (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \
105     defined(__POCC__)
106 #else
107 #define ssize_t int
108 #endif
109
110 #endif /* HAVE_CONFIG_H */
111
112 /*
113  * Recent autoconf versions define these symbols in config.h. We don't
114  * want them (since they collide with the libcurl ones when we build
115  *  --enable-debug) so we undef them again here.
116  */
117
118 #undef PACKAGE_STRING
119 #undef PACKAGE_TARNAME
120 #undef PACKAGE_VERSION
121 #undef PACKAGE_BUGREPORT
122 #undef PACKAGE_NAME
123 #undef VERSION
124 #undef PACKAGE
125
126 /*
127  * Assume a few thing unless they're set by configure
128  */
129
130 #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__)
131 #define HAVE_SYS_TIME_H
132 #endif
133
134 #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
135 #define HAVE_UNISTD_H 1
136 #endif
137
138 #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
139 #define HAVE_SYS_UIO_H
140 #endif
141
142 #if (defined(WIN32) || defined(WATT32)) && \
143    !(defined(__MINGW32__) || defined(NETWARE) || defined(__DJGPP__))
144 /* protos for the functions we provide in windows_port.c */
145 int ares_strncasecmp(const char *s1, const char *s2, int n);
146 int ares_strcasecmp(const char *s1, const char *s2);
147
148 /* use this define magic to prevent us from adding symbol names to the library
149    that is a high-risk to collide with another libraries' attempts to do the
150    same */
151 #define strncasecmp(a,b,c) ares_strncasecmp(a,b,c)
152 #define strcasecmp(a,b) ares_strcasecmp(a,b)
153 #ifdef _MSC_VER
154 #  if _MSC_VER >= 1400
155 #    define strdup(a) _strdup(a)
156 #  endif
157 #endif
158 #endif
159
160 /* IPv6 compatibility */
161 #if !defined(HAVE_AF_INET6)
162 #if defined(HAVE_PF_INET6)
163 #define AF_INET6 PF_INET6
164 #else
165 #define AF_INET6 AF_MAX+1
166 #endif
167 #endif
168
169 /*
170  * Include macros and defines that should only be processed once.
171  */
172
173 #ifndef __SETUP_ONCE_H
174 #include "setup_once.h"
175 #endif
176
177 #endif /* __ARES_SETUP_H */