Commit 08c044be authored by Ghislain MARY's avatar Ghislain MARY

Compile async DNS resolver with Visual Studio.

Lots of changes made so that dns.[ch] compiles without C99.
parent 9ec4a5fc
......@@ -123,6 +123,7 @@
<ClInclude Include="..\..\..\src\belle_sip_messageParser.h" />
<ClInclude Include="..\..\..\src\belle_sip_resolver.h" />
<ClInclude Include="..\..\..\src\channel.h" />
<ClInclude Include="..\..\..\src\dns.h" />
<ClInclude Include="..\..\..\src\listeningpoint_internal.h" />
<ClInclude Include="..\..\..\src\md5.h" />
<ClInclude Include="..\..\..\src\port.h" />
......@@ -168,6 +169,7 @@
<ClCompile Include="..\..\..\src\dialog.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|Win32'">CompileAsC</CompileAs>
</ClCompile>
<ClCompile Include="..\..\..\src\dns.c" />
<ClCompile Include="..\..\..\src\ict.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|Win32'">CompileAsC</CompileAs>
</ClCompile>
......
......@@ -21,7 +21,7 @@ AM_SILENT_RULES(yes)
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CC_C99
dnl AC_PROG_CC_C99
LT_INIT(disable-static win32-dll)
if test -f /etc/debian_version ; then
......
......@@ -75,6 +75,9 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
struct dns_packet *ans;
struct dns_rr_i *I;
int error;
#ifndef HAVE_C99
struct dns_rr_i dns_rr_it;
#endif
if (revents & BELLE_SIP_EVENT_TIMEOUT) {
belle_sip_error("%s timed-out", __FUNCTION__);
......@@ -91,7 +94,12 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
enum dns_section section = DNS_S_AN;
ans = dns_res_fetch(ctx->R, &error);
#ifdef HAVE_C99
I = dns_rr_i_new(ans, .section = 0);
#else
memset(&dns_rr_it, 0, sizeof dns_rr_it);
I = dns_rr_i_init(&dns_rr_it, ans);
#endif
while (dns_rr_grep(&rr, 1, I, ans, &error)) {
if (rr.section == section) {
if ((error = dns_any_parse(dns_any_init(&any, sizeof(any)), &rr, ans))) {
......@@ -124,6 +132,10 @@ static int resolver_process_a_data(belle_sip_resolver_context_t *ctx, unsigned i
static int resolver_start_query(belle_sip_resolver_context_t *ctx, belle_sip_source_func_t datafunc, enum dns_type type, int timeout) {
struct dns_hints *(*hints)() = &dns_hints_local;
struct dns_options *opts;
#ifndef HAVE_C99
struct dns_options opts_st;
#endif
int error;
if (!ctx->name) return -1;
......@@ -135,7 +147,13 @@ static int resolver_start_query(belle_sip_resolver_context_t *ctx, belle_sip_sou
if (!hosts(ctx))
return -1;
if (!(ctx->R = dns_res_open(ctx->resconf, ctx->hosts, dns_hints_mortal(hints(ctx->resconf, &error)), cache(ctx), dns_opts(), &error))) {
#ifdef HAVE_C99
opts = dns_opts();
#else
memset(&opts_st, 0, sizeof opts_st);
opts = &opts_st;
#endif
if (!(ctx->R = dns_res_open(ctx->resconf, ctx->hosts, dns_hints_mortal(hints(ctx->resconf, &error)), cache(ctx), opts, &error))) {
belle_sip_error("%s dns_res_open error [%s]: %s", __FUNCTION__, ctx->name, dns_strerror(error));
return -1;
}
......
This diff is collapsed.
......@@ -49,6 +49,14 @@
#endif
typedef unsigned char DNSBool;
#ifdef _MSC_VER
#define DNS_INLINE __inline
#else
#define DNS_INLINE inline
#endif
/*
* V E R S I O N
*
......@@ -266,24 +274,30 @@ enum dns_rcode {
#define DNS_STRMAXLEN 47 /* "QUESTION|ANSWER|AUTHORITY|ADDITIONAL" */
const char *dns_strsection(enum dns_section, void *, size_t);
#ifdef HAVE_C99
#define dns_strsection3(a, b, c) \
dns_strsection((a), (b), (c))
#define dns_strsection1(a) dns_strsection((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
#define dns_strsection(...) DNS_PP_CALL(DNS_PP_XPASTE(dns_strsection, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
#endif
enum dns_section dns_isection(const char *);
const char *dns_strclass(enum dns_class, void *, size_t);
#ifdef HAVE_C99
#define dns_strclass3(a, b, c) dns_strclass((a), (b), (c))
#define dns_strclass1(a) dns_strclass((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
#define dns_strclass(...) DNS_PP_CALL(DNS_PP_XPASTE(dns_strclass, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
#endif
enum dns_class dns_iclass(const char *);
const char *dns_strtype(enum dns_type, void *, size_t);
#ifdef HAVE_C99
#define dns_strtype3(a, b, c) dns_strtype((a), (b), (c))
#define dns_strtype1(a) dns_strtype((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
#define dns_strtype(...) DNS_PP_CALL(DNS_PP_XPASTE(dns_strtype, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
#endif
enum dns_type dns_itype(const char *);
......@@ -359,12 +373,22 @@ struct dns_header {
#define DNS_P_DICTSIZE 16
#endif
#ifndef HAVE_C99
struct dns_s_memo {
unsigned short base, end;
};
#endif
struct dns_packet {
unsigned short dict[DNS_P_DICTSIZE];
#ifdef HAVE_C99
struct dns_s_memo {
unsigned short base, end;
} qd, an, ns, ar;
#else
struct dns_s_memo qd, an, ns, ar;
#endif
struct { struct dns_packet *cqe_next, *cqe_prev; } cqe;
......@@ -819,7 +843,7 @@ int dns_hosts_loadpath(struct dns_hosts *, const char *);
int dns_hosts_dump(struct dns_hosts *, FILE *);
int dns_hosts_insert(struct dns_hosts *, int, const void *, const void *, _Bool);
int dns_hosts_insert(struct dns_hosts *, int, const void *, const void *, DNSBool);
struct dns_packet *dns_hosts_query(struct dns_hosts *, struct dns_packet *, int *);
......@@ -838,7 +862,7 @@ struct dns_resolv_conf {
char lookup[4 * (1 + (4 * 2))];
struct {
_Bool edns0;
DNSBool edns0;
unsigned ndots;
......@@ -846,11 +870,11 @@ struct dns_resolv_conf {
unsigned attempts;
_Bool rotate;
DNSBool rotate;
_Bool recurse;
DNSBool recurse;
_Bool smart;
DNSBool smart;
enum {
DNS_RESCONF_TCP_ENABLE,
......
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