ReactOS 0.4.15-dev-8127-g6338913
adns_win32.h
Go to the documentation of this file.
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
55extern "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
78#define WIN32_NO_STATUS
79#define _INC_WINDOWS
80#define COM_NO_WINDOWS_H
81#include <windef.h>
82#include <winbase.h>
83#include <objbase.h>
84#include <winsock2.h>
85//#include <windows.h>
86#include <sys/types.h>
87#include <time.h>
88#include <errno.h>
89#include <assert.h>
90#include <limits.h>
91#include <malloc.h>
92#include <signal.h>
93
94#define HAVE_WINSOCK 1
95//#define PRINTFFORMAT(si,tc)
96#define inline __inline
97
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)
102
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
106 */
107#define ADNS_CAPTURE_ERRNO {errno = WSAGetLastError(); WSASetLastError(errno);}
108#define ADNS_CLEAR_ERRNO {WSASetLastError(errno = 0);}
109
110#define ENOBUFS WSAENOBUFS
111
112/* FIXME: there are two types of defines for this,
113 * one points to WSAEWOULDBLOCK and the other is from errno.h */
114#ifdef EWOULDBLOCK
115#undef EWOULDBLOCK
116#endif
117
118#define EWOULDBLOCK WSAEWOULDBLOCK
119
120#define EINPROGRESS WSAEINPROGRESS
121#define EMSGSIZE WSAEMSGSIZE
122#define ENOPROTOOPT WSAENOPROTOOPT
123#define ECONNRESET WSAECONNRESET
124
125//#define NONRETURNING
126//#define NONRETURNPRINTFFORMAT(si,tc)
127
128 /*
129 * UNIX system API for Win32
130 * The following is a quick and dirty implementation of
131 * some UNIX API calls in Win32.
132 * They are used in the dll, but if your project have
133 * it's own implementation of these system calls, simply
134 * undefine ADNS_MAP_UNIXAPI.
135 */
136
137struct iovec
138{
139 char *iov_base;
141};
142
143struct timezone; /* XXX arty */
144
145/*
146 * Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
147 */
149ADNS_API int adns_writev (int FileDescriptor, const struct iovec * iov, int iovCount);
150ADNS_API int adns_inet_aton(const char *cp, struct in_addr *inp);
152
153#ifdef ADNS_DLL
154 ADNS_API void *adns_malloc(const size_t bytes);
155 ADNS_API void *adns_realloc(void *ptr, const size_t bytes);
156 ADNS_API void adns_free(void *ptr);
157#endif
158
159#define gettimeofday(tv, tz) adns_gettimeofday(tv, tz)
160#define writev(FileDescriptor, iov, iovCount) adns_writev(FileDescriptor, iov, iovCount)
161#define inet_aton(ap, inp) adns_inet_aton(ap, inp)
162#define getpid() adns_getpid()
163
164#ifdef ADNS_DLL
165# define malloc(bytes) adns_malloc(bytes)
166# define realloc(ptr, bytes) adns_realloc(ptr, bytes)
167# define free(ptr) adns_free(ptr)
168#endif
169
170/* ---------------- END OF C HEADER -------------- */
171#ifdef __cplusplus
172}
173#endif /* __cplusplus */
174
175#endif /* ADNS_WIN32_H_INCLUDED */
176
ADNS_API int adns_gettimeofday(struct timeval *tv, struct timezone *tz)
ADNS_API int adns_getpid()
ADNS_API int adns_inet_aton(const char *cp, struct in_addr *inp)
ADNS_API int adns_writev(int FileDescriptor, const struct iovec *iov, int iovCount)
#define ADNS_API
Definition: adns_win32.h:66
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
GLbyte GLbyte tz
Definition: glext.h:8756
POINT cp
Definition: magnifier.c:59
static PVOID ptr
Definition: dispmode.c:27
Definition: tcpip.h:126
Definition: linux.h:1700
char * iov_base
Definition: adns_win32.h:139
int iov_len
Definition: adns_win32.h:140
Definition: fake.h:14