]> jfr.im git - irc/ircd-hybrid/bopm.git/commitdiff
configure.in, configure, setup.h.in:
authorandy <redacted>
Thu, 23 May 2002 03:31:22 +0000 (03:31 +0000)
committerandy <redacted>
Thu, 23 May 2002 03:31:22 +0000 (03:31 +0000)
Check for inet_aton()

compat.c, comapt.h:
Provide our own inet_aton() if the system does not have one.

compat.c
compat.h
configure
configure.in
setup.h.in

index 634b48019444beab3cd8c1922454e4048adb8ed2..8fbedf579145bcc2811b4b53ea3182b04678cbc8 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -20,4 +20,42 @@ along with this program; if not, write to the
 */
 
 #include "setup.h"
+
+#include <stdio.h>
+
+#ifdef STDC_HEADERS
+# include <string.h>
+#endif
+
+#ifndef HAVE_INET_ATON
+# include <netinet/in.h>
+#endif
+
 #include "compat.h"
+
+#ifndef HAVE_INET_ATON
+int inet_aton(const char *cp, struct in_addr *inp)
+{
+       unsigned int a1, a2, a3, a4;
+       unsigned long ret;
+
+       if (strcmp(cp, "255.255.255.255") == 0) {
+               inp->s_addr = (unsigned) -1;
+               return 0;
+       }
+
+       if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
+           a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {
+               return 0;
+       }
+
+       ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
+
+       inp->s_addr = htonl(ret);
+       
+       if (inp->s_addr == (unsigned) -1) {
+               return 0;
+       }
+       return 1;
+}
+#endif
index 1da3a77bbc99d4f9362bbb29f404df2b2be4c972..c747514a5854aa6496c239b7625a8eccadbae86c 100644 (file)
--- a/compat.h
+++ b/compat.h
@@ -5,4 +5,8 @@
 #define INADDR_NONE 0xffffffff
 #endif
 
+#ifndef HAVE_INET_ATON
+extern int inet_aton(const char *cp, struct in_addr *inp);
+#endif
+
 #endif
index adb997972b0164d1d30320c19479d459d06b7366..f2a9425c417dd9f491761c94a4163fc46d4b52eb 100755 (executable)
--- a/configure
+++ b/configure
@@ -2777,7 +2777,7 @@ echo "$as_me: error: No select() implementation found" >&2;}
  fi
 fi
 
-for ac_func in socket strdup strstr
+for ac_func in inet_aton socket strdup strstr
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:2783: checking for $ac_func" >&5
index c0794d9e4f4bdc29292f72d3fb162e82d89dc2ff..7e825f0e6c298b719020b6a3b3c7fa162e3e47bc 100644 (file)
@@ -49,7 +49,7 @@ if test "$with_select" = "yes" || test "$have_sys_poll_h" = "no"; then
  fi
 fi
 
-AC_CHECK_FUNCS(socket strdup strstr)
+AC_CHECK_FUNCS(inet_aton socket strdup strstr)
 
 dnl AIX fun
 AC_C_BIGENDIAN
index cd57ef1239269f58d92f03f1e73b59b69b8098ae..c00f8892d2c756e16240c143f9efdbf345e5caec 100644 (file)
@@ -3,6 +3,9 @@
 /* Define if you have the <fcntl.h> header file. */
 #undef HAVE_FCNTL_H
 
+/* Define if you have the `inet_aton' function. */
+#undef HAVE_INET_ATON
+
 /* Define if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H