chiark / gitweb /
Portability fixes (missing struct in_addr, INADDR_LOOPBACK defs, rrs=0
authorian <ian>
Sat, 8 May 1999 15:40:54 +0000 (15:40 +0000)
committerian <ian>
Sat, 8 May 1999 15:40:54 +0000 (15:40 +0000)
ipv rrs.untyped=0, -lsocket, etc.

configure
configure.in
src/event.c
src/general.c

index 5cc73d5044f229722d9c478efe05337ab30ec1f9..720ebb63f2a0e2ed69ab4b0bb57b8e54cbf6fec6 100755 (executable)
--- a/configure
+++ b/configure
@@ -718,23 +718,70 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
+echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+echo "configure:723: checking for socket in -lsocket" >&5
+ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lsocket  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 731 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char socket();
+
+int main() {
+socket()
+; return 0; }
+EOF
+if { (eval echo configure:742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lsocket $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 
  
  echo $ac_n "checking __attribute__((,,))""... $ac_c" 1>&6
-echo "configure:725: checking __attribute__((,,))" >&5
+echo "configure:772: checking __attribute__((,,))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_supported'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 731 "configure"
+#line 778 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((,,))
 ; return 0; }
 EOF
-if { (eval echo configure:738: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:785: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_supported=yes
 else
@@ -756,20 +803,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((noreturn))""... $ac_c" 1>&6
-echo "configure:760: checking __attribute__((noreturn))" >&5
+echo "configure:807: checking __attribute__((noreturn))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_noreturn'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 766 "configure"
+#line 813 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((noreturn))
 ; return 0; }
 EOF
-if { (eval echo configure:773: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:820: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_noreturn=yes
 else
@@ -796,20 +843,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((const))""... $ac_c" 1>&6
-echo "configure:800: checking __attribute__((const))" >&5
+echo "configure:847: checking __attribute__((const))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 806 "configure"
+#line 853 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((const))
 ; return 0; }
 EOF
-if { (eval echo configure:813: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:860: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_const=yes
 else
@@ -836,20 +883,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((format...))""... $ac_c" 1>&6
-echo "configure:840: checking __attribute__((format...))" >&5
+echo "configure:887: checking __attribute__((format...))" >&5
  if eval "test \"`echo '$''{'adns_cv_attribute_format'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 846 "configure"
+#line 893 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))
 ; return 0; }
 EOF
-if { (eval echo configure:853: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:900: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_attribute_format=yes
 else
index 8d40cc1719d59b46f671d6226b318f3710ca7ad8..7a7a59d8af759f762822e3f6b036721a72dd3af0 100644 (file)
@@ -20,6 +20,7 @@ AC_INIT(src/adns.h)
 AC_CONFIG_HEADER(src/config.h)
 AC_PROG_CC
 AC_PROG_RANLIB
+AC_CHECK_LIB(socket,socket)
 ADNS_C_GCCATTRIB
 
 AC_SUBST(WARNS)
index db3dad68e776168a2c645aa14e801413cf837dd7..582e95c54f893bcde8e1d843f6889b6d1e6e304c 100644 (file)
@@ -27,6 +27,8 @@
 #include <stdlib.h>
 
 #include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include "internal.h"
@@ -100,7 +102,7 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
     addr.sin_family= AF_INET;
     addr.sin_port= htons(DNS_PORT);
     addr.sin_addr= ads->servers[ads->tcpserver].addr;
-    r= connect(fd,&addr,sizeof(addr));
+    r= connect(fd,(const struct sockaddr*)&addr,sizeof(addr));
     ads->tcpsocket= fd;
     ads->tcpstate= server_connecting;
     if (r==0) { tcp_connected(ads,now); continue; }
@@ -305,7 +307,8 @@ static int internal_callback(adns_state ads, int maxfd,
     count++;
     for (;;) {
       udpaddrlen= sizeof(udpaddr);
-      r= recvfrom(ads->udpsocket,udpbuf,sizeof(udpbuf),0,&udpaddr,&udpaddrlen);
+      r= recvfrom(ads->udpsocket,udpbuf,sizeof(udpbuf),0,
+                 (struct sockaddr*)&udpaddr,&udpaddrlen);
       if (r<0) {
        if (!(errno == EAGAIN || errno == EWOULDBLOCK ||
              errno == EINTR || errno == ENOMEM || errno == ENOBUFS))
index b701b9f8b57975ecd9ee752ca6ab5d81878e873e..6d4a1b841ce45d240af3e223ed10d04ecc203f1f 100644 (file)
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <sys/socket.h>
+#include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include "internal.h"