Create a branch for header work.

svn path=/branches/header-work/; revision=45691
This commit is contained in:
Timo Kreuzer 2010-02-26 22:57:55 +00:00
parent 14fe274b1c
commit 9ea495ba33
19538 changed files with 0 additions and 1063950 deletions

68
lib/3rdparty/adns/adns_win32/README.TXT vendored Normal file
View file

@ -0,0 +1,68 @@
This is the ADNS resolver library for Windows, ported
by Jarle (jgaa) Aase, jgaa@jgaa.com
ADNS is not officially suppoted for Windows, but this
port provides a 100% native Windows DLL and linker
library for the DLL - suitable for traditional compilers
and linkers under Windows. The library itself is ported to
Microsot Visual C++ 6.0.
The library is tested under Windows 2000 and XP, but should work
with all versions from Windows NT 4 and up, and Windows98
and up. Windows95 is not supported.
If you want to use the library in your own C/C++ project,
you must set the following manifests before including adns.h:
#define ADNS_MAP_UNIXAPI
#define ADNS_DLL
ADNS_MAP_UNIXAPI will enable the Win32 port in the header-
files (else, they will use the defauts for a UNIX system)
ADNS_DLL will enable linking to the exported DLL functions.
Currently I have only made the DLL available. There are two
reasons for this:
1) The DNS protocol is a mess - and it's difficult to make
a foolproof implementation. If a security-problem is
found (or other bugs) - the fix can usually be deployed
just by replacing the DLL.
2) The GPL/LGPL lisence of ADNS (see GPL-vs-LGPL) will allow
you to use the .dll in your project - as far as I can tell.
A statically linked version will only be allowed in GPL
licensed projects.
For more information about this port, see http://adns.jgaa.com
///////////////////////////////////////////////////////
October 13th 2005 jgaa: adns-1.0-win32-05
- Fixed a problem with the return-value from adns_inet_aton()
Thanks to Gerald Combs for reporting the problem.
October 7th 2004 jgaa: adns-1.0-win32-03
- Fixed a problem with error-messages when the program
works off-line.
Thanks to Ulf Lamping for pointing ourt and solving the problem.
April 4th 2004 jgaa: adns-1.0-win32-03
- Fixed broken gettimeofday() function.
- Fixed problem with TCP connections, where the librarry
failed to connect to DNS servers with TCP, and flooded
the servers with TCP connection attempts.
- Made sure that errno was handled corrcetly after all network
(winsock) calls.
- Fixed a few places where noblocking calls were not handled
EAGAIN and EWOULDBLOCK is not the same under Windows.

View file

@ -0,0 +1,130 @@
/*
* adns_unix_calls.c
* - Simple implementation of requiered UNIX system calls and
* library functions.
*/
/*
* This file is
* Copyright (C) 2000, 2002 Jarle (jgaa) Aase <jgaa@jgaa.com>
*
* It is part of adns, which is
* Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
* Copyright (C) 1999 Tony Finch <dot@dotat.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "adns.h"
int adns_writev(int FileDescriptor, const struct iovec * iov, int iovCount)
{
size_t total_len = 0;
int i = 0, r = 0;
char *buf = NULL, *p = NULL;
for(; i < iovCount; i++)
total_len += iov[i].iov_len;
p = buf = (char *)_alloca(total_len);
for(; i < iovCount; i++)
{
memcpy(p, iov[i].iov_base, iov[i].iov_len);
p += iov[i].iov_len;
}
ADNS_CLEAR_ERRNO
r = send(FileDescriptor, buf, total_len, 0);
ADNS_CAPTURE_ERRNO;
return r;
}
int adns_inet_aton(const char *cp, struct in_addr *inp)
{
if (!cp || !*cp || !inp)
{
errno = EINVAL;
return -1;
}
if (!strcmp(cp, "255.255.255.255"))
{
// Special case
inp->s_addr = INADDR_NONE;
return 0;
}
inp->s_addr = inet_addr(cp);
return (inp->s_addr == INADDR_NONE) ? -1 : 0;
}
int adns_getpid()
{
return GetCurrentProcessId();
}
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
static __int64 Adjustment;
__int64 now = 0;
if (!Adjustment)
{
SYSTEMTIME st = {1970,1,0,1,0,0,0};
SystemTimeToFileTime(&st, (LPFILETIME)&Adjustment);
}
if (tz)
{
errno = EINVAL;
return -1;
}
GetSystemTimeAsFileTime((LPFILETIME)&now);
now -= Adjustment;
tv->tv_sec = (long)(now / 10000000);
tv->tv_usec = (long)((now % 10000000) / 10);
return 0;
}
/* Memory allocated in the DLL must be freed in the dll, so
we provide memory manegement functions. */
#ifdef ADNS_DLL
#undef malloc
#undef realloc
#undef free
void *adns_malloc(const size_t bytes)
{
return malloc(bytes);
}
void *adns_realloc(void *ptr, const size_t bytes)
{
return realloc(ptr, bytes);
}
void adns_free(void *ptr)
{
free(ptr);
}
#endif /* ADNS_DLL */

View file

@ -0,0 +1,161 @@
/*
*
* This file is
* Copyright (C) 2000, 2002 Jarle (jgaa) Aase <jgaa@jgaa.com>
*
* It is part of adns, which is
* Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
* Copyright (C) 1999 Tony Finch <dot@dotat.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* For the benefit of certain LGPL'd `omnibus' software which provides
* a uniform interface to various things including adns, I make the
* following additional licence. I do this because the GPL would
* otherwise force either the omnibus software to be GPL'd or for the
* adns-using part to be distributed separately.
*
* So, you may also redistribute and/or modify adns.h (but only the
* public header file adns.h and not any other part of adns) under the
* terms of the GNU Library General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* Note that adns itself is GPL'd. Authors of adns-using applications
* with GPL-incompatible licences, and people who distribute adns with
* applications where the whole distribution is not GPL'd, are still
* likely to be in violation of the GPL. Anyone who wants to do this
* should contact Ian Jackson. Please note that to avoid encouraging
* people to infringe the GPL as it applies the body of adns, Ian thinks
* that if you take advantage of the special exception to redistribute
* just adns.h under the LGPL, you should retain this paragraph in its
* place in the appropriate copyright statements.
*
*
* You should have received a copy of the GNU General Public License,
* or the GNU Library General Public License, as appropriate, along
* with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef ADNS_WIN32_H_INCLUDED
#define ADNS_WIN32_H_INCLUDED
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#if defined(ADNS_DLL)
# ifdef ADNS_DLL_EXPORTS
# define ADNS_API __declspec(dllexport)
# else
# define ADNS_API __declspec(dllimport)
# endif /* ADNS_EXPORTS */
#else
# define ADNS_API
#endif /* ADNS_DLL */
#if defined (_MSC_VER)
#pragma warning(disable:4003)
#endif /* _MSC_VER */
/* ---------------- START OF C HEADER -------------- */
#include <stdlib.h>
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
#include <sys/types.h>
#include <time.h>
#include <errno.h>
#include <assert.h>
#include <limits.h>
#include <malloc.h>
#include <signal.h>
#define HAVE_WINSOCK 1
//#define PRINTFFORMAT(si,tc)
#define inline __inline
#define ADNS_SOCKET SOCKET
#define adns_socket_close(sck) closesocket(sck)
#define adns_socket_read(sck, data, len) recv(sck, (char *)data, len, 0)
#define adns_socket_write(sck, data, len) send(sck, (char *)data, len, 0)
/* Win32 does not set errno on Winsock errors(!)
* We have to map the winsock errors to errno manually
* in order to support the original UNIX error hadnlig
*/
#define ADNS_CAPTURE_ERRNO {errno = WSAGetLastError(); WSASetLastError(errno);}
#define ADNS_CLEAR_ERRNO {WSASetLastError(errno = 0);}
#define ENOBUFS WSAENOBUFS
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define EMSGSIZE WSAEMSGSIZE
#define ENOPROTOOPT WSAENOPROTOOPT
#define ECONNRESET WSAECONNRESET
//#define NONRETURNING
//#define NONRETURNPRINTFFORMAT(si,tc)
/*
* UNIX system API for Win32
* The following is a quick and dirty implementation of
* some UNIX API calls in Win32.
* They are used in the dll, but if your project have
* it's own implementation of these system calls, simply
* undefine ADNS_MAP_UNIXAPI.
*/
struct iovec
{
char *iov_base;
int iov_len;
};
struct timezone; /* XXX arty */
/*
* Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
*/
ADNS_API int adns_gettimeofday(struct timeval *tv, struct timezone *tz);
ADNS_API int adns_writev (int FileDescriptor, const struct iovec * iov, int iovCount);
ADNS_API int adns_inet_aton(const char *cp, struct in_addr *inp);
ADNS_API int adns_getpid();
#ifdef ADNS_DLL
ADNS_API void *adns_malloc(const size_t bytes);
ADNS_API void *adns_realloc(void *ptr, const size_t bytes);
ADNS_API void adns_free(void *ptr);
#endif
#define gettimeofday(tv, tz) adns_gettimeofday(tv, tz)
#define writev(FileDescriptor, iov, iovCount) adns_writev(FileDescriptor, iov, iovCount)
#define inet_aton(ap, inp) adns_inet_aton(ap, inp)
#define getpid() adns_getpid()
#ifdef ADNS_DLL
# define malloc(bytes) adns_malloc(bytes)
# define realloc(ptr, bytes) adns_realloc(ptr, bytes)
# define free(ptr) adns_free(ptr)
#endif
/* ---------------- END OF C HEADER -------------- */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ADNS_WIN32_H_INCLUDED */

64
lib/3rdparty/adns/adns_win32/getopt.c vendored Normal file
View file

@ -0,0 +1,64 @@
/* jgaa oct 9th 2000: Found this on www.
* No copyright information given.
* Slightly modidied.
*
* Origin: http://www.winsite.com/info/pc/win3/winsock/sossntr4.zip/SOSSNT/SRC/GETOPT.C.html
*/
/* got this off net.sources */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "getopt.h"
/*
* get option letter from argument vector
*/
int opterr = 1, /* useless, never set or used */
optind = 1, /* index into parent argv vector */
optopt; /* character checked for validity */
char* optarg; /* argument associated with option */
#define BADCH (int)'?'
#define EMSG ""
#define tell(s) fputs(*argv,stderr);fputs(s,stderr); \
fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
int getopt(int argc, char * const *argv, const char *optstring)
{
static char *place = EMSG; /* option letter processing */
register char *oli; /* option letter list index */
if(!*place) { /* update scanning pointer */
if(optind >= argc || *(place = argv[optind]) != '-' || !*++place)
return(EOF);
if (*place == '-') { /* found "--" */
++optind;
return(EOF);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(optstring,optopt)))
{
if(!*place) ++optind;
tell(": illegal option -- ");
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place) ++optind;
}
else { /* need an argument */
if (*place) optarg = place; /* no white space */
else if (argc <= ++optind) { /* no arg */
place = EMSG;
tell(": option requires an argument -- ");
}
else optarg = argv[optind]; /* white space */
place = EMSG;
++optind;
}
return(optopt); /* dump back option letter */
}

21
lib/3rdparty/adns/adns_win32/getopt.h vendored Normal file
View file

@ -0,0 +1,21 @@
#ifndef GETOPT_H
#define GETOPT_H
#ifdef __cplusplus
extern "C" {
#endif
extern int opterr; /* useless, never set or used */
extern int optind; /* index into parent argv vector */
extern int optopt; /* character checked for validity */
extern char* optarg; /* argument associated with option */
int getopt(int argc, char * const *argv, const char *optstring);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif /* GETOPT_H */

14
lib/3rdparty/adns/adns_win32/timercmp.h vendored Normal file
View file

@ -0,0 +1,14 @@
#ifndef TIMERCMP_H
#define TIMERCMP_H
#ifndef timercmp
/* Taken from sys/time.h on linux. */
# define timercmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? \
((a)->tv_usec CMP (b)->tv_usec) : \
((a)->tv_sec CMP (b)->tv_sec))
# define timerclear(a) ((a)->tv_sec = (a)->tv_usec = 0)
#endif
#endif//TIMERCMP_H