Commit 65df79f3 authored by Pekka Pessi's avatar Pekka Pessi

Added things missing from win32 to new sresolv modules.

darcs-hash:20060411181740-65a35-98172079735a867d599160b8210016461de0ddc3.gz
parent 2e916eb4
......@@ -38,14 +38,34 @@
#include <stdint.h>
#elif HAVE_INTTYPES_H
#include <inttypes.h>
#else
#if defined(_WIN32)
typedef _int8 int8_t;
typedef unsigned _int8 uint8_t;
typedef unsigned _int16 uint16_t;
typedef unsigned _int32 uint32_t;
#endif
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#if HAVE_SIN6
#include <tpipv6.h>
#else
struct sockaddr_storage {
short ss_family;
char ss_pad[126];
};
#endif
#else
#define closesocket(s) close(s)
#endif
#include <time.h>
#include "sofia-resolv/sres.h"
......@@ -55,10 +75,13 @@
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/su_errno.h>
#include "sofia-sip/htable.h"
#include <sofia-sip/su.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
......@@ -71,6 +94,13 @@
#include <assert.h>
#if defined(va_copy)
#elif defined(__va_copy)
#define va_copy(dst, src) __va_copy((dst), (src))
#else
#define va_copy(dst, src) (memcpy(&(dst), &(src), sizeof (va_list)))
#endif
void sres_cache_clean(sres_cache_t *cache, time_t now);
typedef struct sres_message sres_message_t;
......@@ -1662,7 +1692,7 @@ void sres_servers_unref(sres_resolver_t *res,
if (servers[i]->dns_socket != -1) {
if (res->res_updcb)
res->res_updcb(res->res_async, -1, servers[i]->dns_socket);
su_close(servers[i]->dns_socket);
closesocket(servers[i]->dns_socket);
}
}
......@@ -1694,7 +1724,7 @@ int sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
if (dns->dns_socket != -1)
return dns->dns_socket;
s = su_socket(family, SOCK_DGRAM, IPPROTO_UDP);
s = socket(family, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1) {
SU_DEBUG_1(("%s: %s: %s\n", "sres_server_socket", "socket",
su_strerror(su_errno())));
......@@ -1737,7 +1767,7 @@ int sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
SU_DEBUG_1(("%s: %s: %s: %s:%u\n", "sres_server_socket", "connect",
su_strerror(su_errno()),
ipaddr, ntohs(((struct sockaddr_in *)dns->dns_addr)->sin_port)));
su_close(s);
closesocket(s);
return -1;
}
......@@ -1745,7 +1775,7 @@ int sres_server_socket(sres_resolver_t *res, sres_server_t *dns)
if (res->res_updcb(res->res_async, s, -1) < 0) {
SU_DEBUG_1(("%s: %s: %s\n", "sres_server_socket", "update callback",
su_strerror(su_errno())));
su_close(s);
closesocket(s);
return -1;
}
}
......
......@@ -35,13 +35,23 @@
#include <stdint.h>
#elif HAVE_INTTYPES_H
#include <inttypes.h>
#else
#if defined(_WIN32)
typedef _int8 int8_t;
typedef unsigned _int8 uint8_t;
typedef unsigned _int16 uint16_t;
typedef unsigned _int32 uint32_t;
#endif
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#define HAVE_SELECT 1
#endif
typedef struct sres_blocking_s sres_blocking_t;
......@@ -108,9 +118,11 @@ int sres_blocking_update(sres_blocking_t *b,
N--;
b->fds[i].fd = b->fds[N].fd;
b->fds[i].events = b->fds[N].events;
b->fds[N].fd = -1;
#if HAVE_POLL
b->fds[i].events = b->fds[N].events;
b->fds[N].events = 0;
#endif
b->n_sockets = N;
}
......@@ -164,9 +176,21 @@ int sres_blocking_complete(sres_blocking_context_t *c)
n = c->block->fds[n].fd + 1;
}
n = select(n, readfds, NULL, writefds, timeval);
XXX;
n = select(n, readfds, NULL, errorfds, timeval);
if (n <= 0)
sres_resolver_timer(c->resolver, -1);
else for (i = 0; i < c->block->n_sockets; i++) {
if (c->block->fds[i].fd > n)
continue;
if (FD_ISSET(c->block->fds[i].fd, errorfds))
sres_resolver_error(c->resolver, c->block->fds[i].fd);
else if (FD_ISSET(c->block->fds[i].fd, readfds))
sres_resolver_receive(c->resolver, c->block->fds[i].fd);
else
continue;
break;
}
#endif
}
......
......@@ -38,15 +38,24 @@
#include <stdint.h>
#elif HAVE_INTTYPES_H
#include <inttypes.h>
#else
#if defined(_WIN32)
typedef unsigned _int8 uint8_t;
typedef unsigned _int16 uint16_t;
typedef unsigned _int32 uint32_t;
#endif
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#include <time.h>
#include "sofia-resolv/sres_cache.h"
#include "sofia-resolv/sres_record.h"
......@@ -62,7 +71,6 @@
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment