'Fix' windows builds
[platform/upstream/c-ares.git] / setup.h
1 #ifndef ARES_SETUP_H
2 #define ARES_SETUP_H
3
4 /* Copyright (C) 2004 - 2005 by Daniel Stenberg et al
5  *
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation for any purpose and without fee is hereby granted, provided
8  * that the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of M.I.T. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  M.I.T. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  */
16
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #else
20
21 #ifdef WIN32
22 #include "config-win32.h"
23 #endif
24
25
26 /* 
27  * Include header files for windows builds before redefining anything.
28  * Use this preproessor block only to include or exclude windows.h, 
29  * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs 
30  * to any other further and independant block.
31  */
32
33 #ifdef WIN32
34 #  ifdef HAVE_WINDOWS_H
35 #    ifndef WIN32_LEAN_AND_MEAN
36 #      define WIN32_LEAN_AND_MEAN
37 #    endif
38 #    include <windows.h>
39 #    ifdef HAVE_WINSOCK2_H
40 #      include <winsock2.h>
41 #      ifdef HAVE_WS2TCPIP_H
42 #         include <ws2tcpip.h>
43 #      endif
44 #    else
45 #      ifdef HAVE_WINSOCK_H
46 #        include <winsock.h>
47 #      endif
48 #    endif
49 #  endif
50 #endif
51
52
53 /* simple work-around for now, for systems without configure support */
54 #ifndef __DJGPP__
55 #define ssize_t int
56 #endif
57 #ifndef _MSC_VER
58 #define socklen_t int
59 #endif
60 #endif  /* HAVE_CONFIG_H */
61
62 /* Recent autoconf versions define these symbols in config.h. We don't want
63    them (since they collide with the libcurl ones when we build
64    --enable-debug) so we undef them again here. */
65 #undef PACKAGE_STRING
66 #undef PACKAGE_TARNAME
67 #undef PACKAGE_VERSION
68 #undef PACKAGE_BUGREPORT
69 #undef PACKAGE_NAME
70 #undef VERSION
71 #undef PACKAGE
72
73 /* now typedef our socket type */
74 #if defined(WIN32) && !defined(WATT32)
75 typedef SOCKET ares_socket_t;
76 #define ARES_SOCKET_BAD INVALID_SOCKET
77 #else
78 typedef int ares_socket_t;
79 #define ARES_SOCKET_BAD -1
80 #endif
81
82 /* Assume a few thing unless they're set by configure
83  */
84 #if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER)
85 #define HAVE_SYS_TIME_H
86 #endif
87
88 #if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
89 #define HAVE_UNISTD_H 1
90 #endif
91
92 #if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS)
93 #define HAVE_SYS_UIO_H
94 #endif
95
96 #if (defined(WIN32) || defined(WATT32)) && \
97    !(defined(__MINGW32__) || defined(NETWARE) || defined(__DJGPP__))
98 /* protos for the functions we provide in windows_port.c */
99 int ares_strncasecmp(const char *s1, const char *s2, int n);
100 int ares_strcasecmp(const char *s1, const char *s2);
101
102 /* use this define magic to prevent us from adding symbol names to the library
103    that is a high-risk to collide with another libraries' attempts to do the
104    same */
105 #define strncasecmp(a,b,c) ares_strncasecmp(a,b,c)
106 #define strcasecmp(a,b) ares_strcasecmp(a,b)
107 #endif
108
109 /* IPv6 compatibility */
110 #if !defined(HAVE_AF_INET6)
111 #if defined(HAVE_PF_INET6)
112 #define AF_INET6 PF_INET6
113 #else
114 #define AF_INET6 AF_MAX+1
115 #endif
116 #endif
117
118 #endif /* ARES_SETUP_H */