[SHELL32]
[reactos.git] / reactos / lib / 3rdparty / adns / adns_win32 / adns_win32.h
1 /*
2 *
3 * This file is
4 * Copyright (C) 2000, 2002 Jarle (jgaa) Aase <jgaa@jgaa.com>
5 *
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>
9 *
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)
13 * any later version.
14 *
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.
19 *
20 *
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.
26 *
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.
32 *
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.
42 *
43 *
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.
48 *
49 */
50
51 #ifndef ADNS_WIN32_H_INCLUDED
52 #define ADNS_WIN32_H_INCLUDED
53
54 #ifdef __cplusplus
55 extern "C"
56 {
57 #endif /* __cplusplus */
58
59 #if defined(ADNS_DLL)
60 # ifdef ADNS_DLL_EXPORTS
61 # define ADNS_API __declspec(dllexport)
62 # else
63 # define ADNS_API __declspec(dllimport)
64 # endif /* ADNS_EXPORTS */
65 #else
66 # define ADNS_API
67 #endif /* ADNS_DLL */
68
69 #if defined (_MSC_VER)
70 #pragma warning(disable:4003)
71 #endif /* _MSC_VER */
72
73 /* ---------------- START OF C HEADER -------------- */
74
75 #include <stdlib.h>
76 #include <stdio.h>
77 #include <winsock2.h>
78 #include <windows.h>
79 #include <sys/types.h>
80 #include <time.h>
81 #include <errno.h>
82 #include <assert.h>
83 #include <limits.h>
84 #include <malloc.h>
85 #include <signal.h>
86
87 #define HAVE_WINSOCK 1
88 //#define PRINTFFORMAT(si,tc)
89 #define inline __inline
90
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)
95
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
99 */
100 #define ADNS_CAPTURE_ERRNO {errno = WSAGetLastError(); WSASetLastError(errno);}
101 #define ADNS_CLEAR_ERRNO {WSASetLastError(errno = 0);}
102
103 #define ENOBUFS WSAENOBUFS
104 #define EWOULDBLOCK WSAEWOULDBLOCK
105 #define EINPROGRESS WSAEINPROGRESS
106 #define EMSGSIZE WSAEMSGSIZE
107 #define ENOPROTOOPT WSAENOPROTOOPT
108 #define ECONNRESET WSAECONNRESET
109
110 //#define NONRETURNING
111 //#define NONRETURNPRINTFFORMAT(si,tc)
112
113 /*
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.
120 */
121
122 struct iovec
123 {
124 char *iov_base;
125 int iov_len;
126 };
127
128 struct timezone; /* XXX arty */
129
130 /*
131 * Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
132 */
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();
137
138 #ifdef ADNS_DLL
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);
142 #endif
143
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()
148
149 #ifdef ADNS_DLL
150 # define malloc(bytes) adns_malloc(bytes)
151 # define realloc(ptr, bytes) adns_realloc(ptr, bytes)
152 # define free(ptr) adns_free(ptr)
153 #endif
154
155 /* ---------------- END OF C HEADER -------------- */
156 #ifdef __cplusplus
157 }
158 #endif /* __cplusplus */
159
160 #endif /* ADNS_WIN32_H_INCLUDED */
161