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 -------------- */
78 #define WIN32_NO_STATUS
80 #define COM_NO_WINDOWS_H
85 //#include <windows.h>
86 #include <sys/types.h>
94 #define HAVE_WINSOCK 1
95 //#define PRINTFFORMAT(si,tc)
96 #define inline __inline
98 #define ADNS_SOCKET SOCKET
99 #define adns_socket_close(sck) closesocket(sck)
100 #define adns_socket_read(sck, data, len) recv(sck, (char *)data, len, 0)
101 #define adns_socket_write(sck, data, len) send(sck, (char *)data, len, 0)
103 /* Win32 does not set errno on Winsock errors(!)
104 * We have to map the winsock errors to errno manually
105 * in order to support the original UNIX error hadnlig
107 #define ADNS_CAPTURE_ERRNO {errno = WSAGetLastError(); WSASetLastError(errno);}
108 #define ADNS_CLEAR_ERRNO {WSASetLastError(errno = 0);}
110 #define ENOBUFS WSAENOBUFS
111 #define EWOULDBLOCK WSAEWOULDBLOCK
112 #define EINPROGRESS WSAEINPROGRESS
113 #define EMSGSIZE WSAEMSGSIZE
114 #define ENOPROTOOPT WSAENOPROTOOPT
115 #define ECONNRESET WSAECONNRESET
117 //#define NONRETURNING
118 //#define NONRETURNPRINTFFORMAT(si,tc)
121 * UNIX system API for Win32
122 * The following is a quick and dirty implementation of
123 * some UNIX API calls in Win32.
124 * They are used in the dll, but if your project have
125 * it's own implementation of these system calls, simply
126 * undefine ADNS_MAP_UNIXAPI.
135 struct timezone
; /* XXX arty */
138 * Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
140 ADNS_API
int adns_gettimeofday(struct timeval
*tv
, struct timezone
*tz
);
141 ADNS_API
int adns_writev (int FileDescriptor
, const struct iovec
* iov
, int iovCount
);
142 ADNS_API
int adns_inet_aton(const char *cp
, struct in_addr
*inp
);
143 ADNS_API
int adns_getpid();
146 ADNS_API
void *adns_malloc(const size_t bytes
);
147 ADNS_API
void *adns_realloc(void *ptr
, const size_t bytes
);
148 ADNS_API
void adns_free(void *ptr
);
151 #define gettimeofday(tv, tz) adns_gettimeofday(tv, tz)
152 #define writev(FileDescriptor, iov, iovCount) adns_writev(FileDescriptor, iov, iovCount)
153 #define inet_aton(ap, inp) adns_inet_aton(ap, inp)
154 #define getpid() adns_getpid()
157 # define malloc(bytes) adns_malloc(bytes)
158 # define realloc(ptr, bytes) adns_realloc(ptr, bytes)
159 # define free(ptr) adns_free(ptr)
162 /* ---------------- END OF C HEADER -------------- */
165 #endif /* __cplusplus */
167 #endif /* ADNS_WIN32_H_INCLUDED */