[asterisk-commits] file: trunk r55763 - /trunk/main/dns.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 20 18:05:26 MST 2007


Author: file
Date: Tue Feb 20 19:05:26 2007
New Revision: 55763

URL: http://svn.digium.com/view/asterisk?view=rev&rev=55763
Log:
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.

Modified:
    trunk/main/dns.c

Modified: trunk/main/dns.c
URL: http://svn.digium.com/view/asterisk/trunk/main/dns.c?view=diff&rev=55763&r1=55762&r2=55763
==============================================================================
--- trunk/main/dns.c (original)
+++ trunk/main/dns.c Tue Feb 20 19:05:26 2007
@@ -48,9 +48,21 @@
 
 #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 @@
 	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 @@
 	return 0;
 }
 
-#if !HAVE_RES_NINIT
+#ifndef HAVE_RES_NINIT
 AST_MUTEX_DEFINE_STATIC(res_lock);
 #endif
 
@@ -190,13 +202,13 @@
 	   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 @@
 		else
 			ret = 1;
 	}
-#if HAVE_RES_NINIT
+#ifdef HAVE_RES_NINIT
 	res_nclose(&dnsstate);
 #else
 #ifndef __APPLE__



More information about the asterisk-commits mailing list