added ares_process_fd() to allow applications to ask for processing on
[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 #ifndef HAVE_WS2TCPIP_H
101 #define socklen_t int
102 #endif
103
104 #endif /* HAVE_CONFIG_H */
105
106 /*
107  * Recent autoconf versions define these symbols in config.h. We don't
108  * want them (since they collide with the libcurl ones when we build
109  *  --enable-debug) so we undef them again here.
110  */
111
112 #undef PACKAGE_STRING
113 #undef PACKAGE_TARNAME
114 #undef PACKAGE_VERSION
115 #undef PACKAGE_BUGREPORT
116 #undef PACKAGE_NAME
117 #undef VERSION
118 #undef PACKAGE
119
120 /*
121  * Assume a few thing unless they're set by configure
122  */
123
124 #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__)
125 #define HAVE_SYS_TIME_H
126 #endif
127
128 #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
129 #define HAVE_UNISTD_H 1
130 #endif
131
132 #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
133 #define HAVE_SYS_UIO_H
134 #endif
135
136 #if (defined(WIN32) || defined(WATT32)) && \
137    !(defined(__MINGW32__) || defined(NETWARE) || defined(__DJGPP__))
138 /* protos for the functions we provide in windows_port.c */
139 int ares_strncasecmp(const char *s1, const char *s2, int n);
140 int ares_strcasecmp(const char *s1, const char *s2);
141
142 /* use this define magic to prevent us from adding symbol names to the library
143    that is a high-risk to collide with another libraries' attempts to do the
144    same */
145 #define strncasecmp(a,b,c) ares_strncasecmp(a,b,c)
146 #define strcasecmp(a,b) ares_strcasecmp(a,b)
147 #endif
148
149 /* IPv6 compatibility */
150 #if !defined(HAVE_AF_INET6)
151 #if defined(HAVE_PF_INET6)
152 #define AF_INET6 PF_INET6
153 #else
154 #define AF_INET6 AF_MAX+1
155 #endif
156 #endif
157
158 /*
159  * Include macros and defines that should only be processed once.
160  */
161
162 #ifndef __SETUP_ONCE_H
163 #include "setup_once.h"
164 #endif
165
166 #endif /* __ARES_SETUP_H */