aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-09-11 19:40:09 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-09-11 19:40:09 +0000
commit264274bbfe36cc723813bea96e45fc438229f6ab (patch)
treec2fe60dc2078463e19d3900dda5cc4d1fa10682f
parente291f58d20c4e96f7502fba8c89e556633291b4f (diff)
downloadfetchmail-264274bbfe36cc723813bea96e45fc438229f6ab.tar.gz
fetchmail-264274bbfe36cc723813bea96e45fc438229f6ab.tar.bz2
fetchmail-264274bbfe36cc723813bea96e45fc438229f6ab.zip
Supply inet_aton if needed.
svn path=/trunk/; revision=1331
-rw-r--r--interface.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/interface.c b/interface.c
index 58f6e0a4..3e20f7af 100644
--- a/interface.c
+++ b/interface.c
@@ -110,6 +110,34 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo)
return(result);
}
+#ifndef HAVE_INET_ATON
+/*
+ * Note: This is not a true replacement for inet_aton(), as it won't
+ * do the right thing on "255.255.255.255" (which translates to -1 on
+ * most machines). Fortunately this code will be used only if you're
+ * on an older Linux that lacks a real implementation.
+ */
+#ifdef HAVE_NETINET_IN_SYSTM_H
+# include <sys/types.h>
+# include <netinet/in_systm.h>
+#endif
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+static int inet_aton(const char *cp, struct in_addr *inp) {
+ long addr;
+
+ addr = inet_addr(cp);
+ if (addr == ((long) -1)) return 0;
+
+ memcpy(inp, &addr, sizeof(addr));
+ return 1;
+}
+#endif HAVE_INET_ATON
+
void interface_parse(char *buf, struct hostdata *hp)
/* parse 'interface' specification */
{