4 * Copyright (C) 2000, 2002 Jarle (jgaa) Aase <jgaa@jgaa.com>
6 * It is part of adns, which is
7 * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
8 * Copyright (C) 1999 Tony Finch <dot@dotat.at>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 * For the benefit of certain LGPL'd `omnibus' software which provides
22 * a uniform interface to various things including adns, I make the
23 * following additional licence. I do this because the GPL would
24 * otherwise force either the omnibus software to be GPL'd or for the
25 * adns-using part to be distributed separately.
27 * So, you may also redistribute and/or modify adns.h (but only the
28 * public header file adns.h and not any other part of adns) under the
29 * terms of the GNU Library General Public License as published by the
30 * Free Software Foundation; either version 2 of the License, or (at
31 * your option) any later version.
33 * Note that adns itself is GPL'd. Authors of adns-using applications
34 * with GPL-incompatible licences, and people who distribute adns with
35 * applications where the whole distribution is not GPL'd, are still
36 * likely to be in violation of the GPL. Anyone who wants to do this
37 * should contact Ian Jackson. Please note that to avoid encouraging
38 * people to infringe the GPL as it applies the body of adns, Ian thinks
39 * that if you take advantage of the special exception to redistribute
40 * just adns.h under the LGPL, you should retain this paragraph in its
41 * place in the appropriate copyright statements.
44 * You should have received a copy of the GNU General Public License,
45 * or the GNU Library General Public License, as appropriate, along
46 * with this program; if not, write to the Free Software Foundation,
47 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51 #ifndef ADNS_WIN32_H_INCLUDED
52 #define ADNS_WIN32_H_INCLUDED
57 #endif /* __cplusplus */
60 # ifdef ADNS_DLL_EXPORTS
61 # define ADNS_API __declspec(dllexport)
63 # define ADNS_API __declspec(dllimport)
64 # endif /* ADNS_EXPORTS */
69 #if defined (_MSC_VER)
70 #pragma warning(disable:4003)
73 /* ---------------- START OF C HEADER -------------- */
79 #include <sys/types.h>
87 #define HAVE_WINSOCK 1
88 //#define PRINTFFORMAT(si,tc)
89 #define inline __inline
91 #define ADNS_SOCKET SOCKET
92 #define adns_socket_close(sck) closesocket(sck)
93 #define adns_socket_read(sck, data, len) recv(sck, (char *)data, len, 0)
94 #define adns_socket_write(sck, data, len) send(sck, (char *)data, len, 0)
96 /* Win32 does not set errno on Winsock errors(!)
97 * We have to map the winsock errors to errno manually
98 * in order to support the original UNIX error hadnlig
100 #define ADNS_CAPTURE_ERRNO {errno = WSAGetLastError(); WSASetLastError(errno);}
101 #define ADNS_CLEAR_ERRNO {WSASetLastError(errno = 0);}
103 #define ENOBUFS WSAENOBUFS
104 #define EWOULDBLOCK WSAEWOULDBLOCK
105 #define EINPROGRESS WSAEINPROGRESS
106 #define EMSGSIZE WSAEMSGSIZE
107 #define ENOPROTOOPT WSAENOPROTOOPT
108 #define ECONNRESET WSAECONNRESET
110 //#define NONRETURNING
111 //#define NONRETURNPRINTFFORMAT(si,tc)
114 * UNIX system API for Win32
115 * The following is a quick and dirty implementation of
116 * some UNIX API calls in Win32.
117 * They are used in the dll, but if your project have
118 * it's own implementation of these system calls, simply
119 * undefine ADNS_MAP_UNIXAPI.
128 struct timezone
; /* XXX arty */
131 * Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
133 ADNS_API
int adns_gettimeofday(struct timeval
*tv
, struct timezone
*tz
);
134 ADNS_API
int adns_writev (int FileDescriptor
, const struct iovec
* iov
, int iovCount
);
135 ADNS_API
int adns_inet_aton(const char *cp
, struct in_addr
*inp
);
136 ADNS_API
int adns_getpid();
139 ADNS_API
void *adns_malloc(const size_t bytes
);
140 ADNS_API
void *adns_realloc(void *ptr
, const size_t bytes
);
141 ADNS_API
void adns_free(void *ptr
);
144 #define gettimeofday(tv, tz) adns_gettimeofday(tv, tz)
145 #define writev(FileDescriptor, iov, iovCount) adns_writev(FileDescriptor, iov, iovCount)
146 #define inet_aton(ap, inp) adns_inet_aton(ap, inp)
147 #define getpid() adns_getpid()
150 # define malloc(bytes) adns_malloc(bytes)
151 # define realloc(ptr, bytes) adns_realloc(ptr, bytes)
152 # define free(ptr) adns_free(ptr)
155 /* ---------------- END OF C HEADER -------------- */
158 #endif /* __cplusplus */
160 #endif /* ADNS_WIN32_H_INCLUDED */