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