Make it build and fix tests in cygwin

This commit is contained in:
Erik Ekman 2009-01-24 16:39:05 +00:00
parent 86ee760e8b
commit 5352b5075e
8 changed files with 77 additions and 3 deletions

View File

@ -15,7 +15,11 @@
*/ */
#include <arpa/inet.h> #include <arpa/inet.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#include <netinet/in.h> #include <netinet/in.h>
#ifdef DARWIN #ifdef DARWIN
#include <arpa/nameser8_compat.h> #include <arpa/nameser8_compat.h>
@ -38,7 +42,7 @@
#include "common.h" #include "common.h"
/* daemon(3) exists only in 4.4BSD or later, and in GNU libc */ /* daemon(3) exists only in 4.4BSD or later, and in GNU libc */
#if !(defined(BSD) && (BSD >= 199306)) && !defined(__GLIBC__) #if !(defined(__CYGWIN__)) && !(defined(BSD) && (BSD >= 199306)) && !defined(__GLIBC__)
static int daemon(int nochdir, int noclose) static int daemon(int nochdir, int noclose)
{ {
int fd, i; int fd, i;

View File

@ -15,7 +15,11 @@
*/ */
#include <arpa/inet.h> #include <arpa/inet.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#ifdef DARWIN #ifdef DARWIN
#include <arpa/nameser8_compat.h> #include <arpa/nameser8_compat.h>
#endif #endif

View File

@ -32,7 +32,11 @@
#include <pwd.h> #include <pwd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <zlib.h> #include <zlib.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#ifdef DARWIN #ifdef DARWIN
#include <arpa/nameser8_compat.h> #include <arpa/nameser8_compat.h>
#endif #endif

View File

@ -36,7 +36,11 @@
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <zlib.h> #include <zlib.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#ifdef DARWIN #ifdef DARWIN
#include <arpa/nameser8_compat.h> #include <arpa/nameser8_compat.h>
#endif #endif
@ -799,6 +803,7 @@ read_dns(int fd, struct query *q)
memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen); memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen);
q->fromlen = addrlen; q->fromlen = addrlen;
#ifndef __CYGWIN__
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg)) { cmsg = CMSG_NXTHDR(&msg, cmsg)) {
@ -809,7 +814,7 @@ read_dns(int fd, struct query *q)
break; break;
} }
} }
#endif
return strlen(q->name); return strlen(q->name);
} else if (r < 0) { } else if (r < 0) {
/* Error */ /* Error */

49
src/windows.h Normal file
View File

@ -0,0 +1,49 @@
#define T_A 1
#define T_NS 2
#define T_NULL 10
#define C_IN 1
#define NOERROR 0
#define SERVFAIL 2
#define NXDOMAIN 3
#define NOTIMP 4
#define REFUSED 5
typedef struct {
unsigned id :16; /* query identification number */
#if BYTE_ORDER == BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */
unsigned aa: 1; /* authoritive answer */
unsigned tc: 1; /* truncated message */
unsigned rd: 1; /* recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /* recursion available */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /* authentic data from named */
unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */
unsigned aa :1; /* authoritive answer */
unsigned opcode :4; /* purpose of message */
unsigned qr :1; /* response flag */
/* fields in fourth byte */
unsigned rcode :4; /* response code */
unsigned cd: 1; /* checking disabled by resolver */
unsigned ad: 1; /* authentic data from named */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /* recursion available */
#endif
/* remaining bytes */
unsigned qdcount :16; /* number of question entries */
unsigned ancount :16; /* number of answer entries */
unsigned nscount :16; /* number of authority entries */
unsigned arcount :16; /* number of resource entries */
} HEADER;

View File

@ -23,5 +23,5 @@ $(TEST): $(OBJS) $(SRCOBJS)
clean: clean:
@echo "Cleaning tests/" @echo "Cleaning tests/"
@rm -f *~ *.core $(TEST) $(OBJS) @rm -f *~ *.core $(TEST){,exe} $(OBJS)

View File

@ -23,7 +23,11 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#include "common.h" #include "common.h"
#include "dns.h" #include "dns.h"

View File

@ -18,7 +18,11 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef __CYGWIN__
#include <arpa/nameser.h> #include <arpa/nameser.h>
#else
#include "windows.h"
#endif
#ifdef DARWIN #ifdef DARWIN
#include <arpa/nameser8_compat.h> #include <arpa/nameser8_compat.h>
#endif #endif