aboutsummaryrefslogtreecommitdiffstats
path: root/main/dns.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-21 01:05:26 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-21 01:05:26 +0000
commit49b7980600f1acdbc02be08c50b20f1a90a53580 (patch)
treea8f6c2f42c715f3646041718b9b8b173ddfdaf90 /main/dns.c
parentf67cdc6fd3defec98f42de823e98450c9cd82c21 (diff)
Return trunk to a state where it compiles under Darwin. The byte order stuff is ugly, if anyone wants to clean it up... by all means do so.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@55763 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/dns.c')
-rw-r--r--main/dns.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/main/dns.c b/main/dns.c
index ff7dde745..52a4b8ddb 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -48,9 +48,21 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define MAX_SIZE 4096
+#ifdef __PDP_ENDIAN
+#if __BYTE_ORDER == __PDP_ENDIAN
+#define DETERMINED_BYTE_ORDER __LITTLE_ENDIAN
+#endif
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define DETERMINED_BYTE_ORDER __BIG_ENDIAN
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define DETERMINED_BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
typedef struct {
unsigned id:16; /*!< query identification number */
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if DETERMINED_BYTE_ORDER == __BIG_ENDIAN
/* fields in third byte */
unsigned qr:1; /*!< response flag */
unsigned opcode:4; /*!< purpose of message */
@@ -64,7 +76,7 @@ typedef struct {
unsigned cd:1; /*!< checking disabled by resolver */
unsigned rcode:4; /*!< response code */
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
+#if DETERMINED_BYTE_ORDER == __LITTLE_ENDIAN
/* fields in third byte */
unsigned rd:1; /*!< recursion desired */
unsigned tc:1; /*!< truncated message */
@@ -178,7 +190,7 @@ static int dns_parse_answer(void *context,
return 0;
}
-#if !HAVE_RES_NINIT
+#ifndef HAVE_RES_NINIT
AST_MUTEX_DEFINE_STATIC(res_lock);
#endif
@@ -190,13 +202,13 @@ int ast_search_dns(void *context,
const char *dname, int class, int type,
int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer))
{
-#if HAVE_RES_NINIT
+#ifdef HAVE_RES_NINIT
struct __res_state dnsstate;
#endif
unsigned char answer[MAX_SIZE];
int res, ret = -1;
-#if HAVE_RES_NINIT
+#ifdef HAVE_RES_NINIT
res_ninit(&dnsstate);
res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
#else
@@ -217,7 +229,7 @@ int ast_search_dns(void *context,
else
ret = 1;
}
-#if HAVE_RES_NINIT
+#ifdef HAVE_RES_NINIT
res_nclose(&dnsstate);
#else
#ifndef __APPLE__