Windows build targets have socklen_t definition in ws2tcpip.h but some
[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 #if !defined(WIN32) && defined(__WIN32__)
20 /* Borland fix */
21 #define WIN32
22 #endif
23
24 #if !defined(WIN32) && defined(_WIN32)
25 /* VS2005 on x64 fix */
26 #define WIN32
27 #endif
28
29 /*
30  * Include configuration script results or hand-crafted
31  * configuration file for platforms which lack config tool.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #else
37
38 #ifdef WIN32
39 #include "config-win32.h"
40 #endif
41
42 #endif /* HAVE_CONFIG_H */
43
44 /*
45  * Include header files for windows builds before redefining anything.
46  * Use this preproessor block only to include or exclude windows.h,
47  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
48  * to any other further and independant block.  Under Cygwin things work
49  * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
50  * never be included when __CYGWIN__ is defined.  configure script takes
51  * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
52  * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
53  */
54
55 #ifdef HAVE_WINDOWS_H
56 #  ifndef WIN32_LEAN_AND_MEAN
57 #    define WIN32_LEAN_AND_MEAN
58 #  endif
59 #  include <windows.h>
60 #  ifdef HAVE_WINSOCK2_H
61 #    include <winsock2.h>
62 #    ifdef HAVE_WS2TCPIP_H
63 #       include <ws2tcpip.h>
64 #    endif
65 #  else
66 #    ifdef HAVE_WINSOCK_H
67 #      include <winsock.h>
68 #    endif
69 #  endif
70 #endif
71
72 /*
73  * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
74  * define USE_WINSOCK to 1 if we have and use WINSOCK  API, else
75  * undefine USE_WINSOCK.
76  */
77
78 #undef USE_WINSOCK
79
80 #ifdef HAVE_WINSOCK2_H
81 #  define USE_WINSOCK 2
82 #else
83 #  ifdef HAVE_WINSOCK_H
84 #    define USE_WINSOCK 1
85 #  endif
86 #endif
87
88 /*
89  * Work-arounds for systems without configure support
90  */
91
92 #ifndef HAVE_CONFIG_H
93
94 #if defined(__DJGPP__) || (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \
95     defined(__POCC__)
96 #else
97 #define ssize_t int
98 #endif
99
100 #endif /* HAVE_CONFIG_H */
101
102 /*
103  * Recent autoconf versions define these symbols in config.h. We don't
104  * want them (since they collide with the libcurl ones when we build
105  *  --enable-debug) so we undef them again here.
106  */
107
108 #undef PACKAGE_STRING
109 #undef PACKAGE_TARNAME
110 #undef PACKAGE_VERSION
111 #undef PACKAGE_BUGREPORT
112 #undef PACKAGE_NAME
113 #undef VERSION
114 #undef PACKAGE
115
116 /*
117  * Assume a few thing unless they're set by configure
118  */
119
120 #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__)
121 #define HAVE_SYS_TIME_H
122 #endif
123
124 #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
125 #define HAVE_UNISTD_H 1
126 #endif
127
128 #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
129 #define HAVE_SYS_UIO_H
130 #endif
131
132 #if (defined(WIN32) || defined(WATT32)) && \
133    !(defined(__MINGW32__) || defined(NETWARE) || defined(__DJGPP__))
134 /* protos for the functions we provide in windows_port.c */
135 int ares_strncasecmp(const char *s1, const char *s2, int n);
136 int ares_strcasecmp(const char *s1, const char *s2);
137
138 /* use this define magic to prevent us from adding symbol names to the library
139    that is a high-risk to collide with another libraries' attempts to do the
140    same */
141 #define strncasecmp(a,b,c) ares_strncasecmp(a,b,c)
142 #define strcasecmp(a,b) ares_strcasecmp(a,b)
143 #ifdef _MSC_VER
144 #  if _MSC_VER >= 1400
145 #    define strdup(a) _strdup(a)
146 #  endif
147 #endif
148 #endif
149
150 /* IPv6 compatibility */
151 #if !defined(HAVE_AF_INET6)
152 #if defined(HAVE_PF_INET6)
153 #define AF_INET6 PF_INET6
154 #else
155 #define AF_INET6 AF_MAX+1
156 #endif
157 #endif
158
159 /*
160  * Include macros and defines that should only be processed once.
161  */
162
163 #ifndef __SETUP_ONCE_H
164 #include "setup_once.h"
165 #endif
166
167 #endif /* __ARES_SETUP_H */