split inet_addr and inet_ntoa back into their own files
authorRich Felker <dalias@aerifal.cx>
Tue, 22 Oct 2013 02:05:29 +0000 (22:05 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 22 Oct 2013 02:05:29 +0000 (22:05 -0400)
despite being practically deprecated, these functions are still part
of the standard and thus cannot reside in a file that also contains
namespace pollution. this reverts some of the changes made in commit
e40f48a421a9176e3e298b5bac75f0355b219e58.

src/network/inet_addr.c [new file with mode: 0644]
src/network/inet_legacy.c
src/network/inet_ntoa.c [new file with mode: 0644]

diff --git a/src/network/inet_addr.c b/src/network/inet_addr.c
new file mode 100644 (file)
index 0000000..8413728
--- /dev/null
@@ -0,0 +1,11 @@
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include "__dns.h"
+
+in_addr_t inet_addr(const char *p)
+{
+       struct sockaddr_in sin;
+       if (__ipparse(&sin, AF_INET, p)) return -1;
+       return sin.sin_addr.s_addr;
+}
index e802557b61b89736f213477306c9653bb906e766..9907c541154ff758a187a519c1b30ee4345dc43a 100644 (file)
@@ -1,16 +1,8 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <stdio.h>
 #include "__dns.h"
 
-in_addr_t inet_addr(const char *p)
-{
-       struct sockaddr_in sin;
-       if (__ipparse(&sin, AF_INET, p)) return -1;
-       return sin.sin_addr.s_addr;
-}
-
 in_addr_t inet_network(const char *p)
 {
        return ntohl(inet_addr(p));
@@ -21,14 +13,6 @@ int inet_aton(const char *cp, struct in_addr *inp)
        return inet_pton(AF_INET, cp, (void *)inp) > 0;
 }
 
-char *inet_ntoa(struct in_addr in)
-{
-       static char buf[16];
-       unsigned char *a = (void *)&in;
-       snprintf(buf, sizeof buf, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
-       return buf;
-}
-
 struct in_addr inet_makeaddr(int net, int host)
 {
        uint32_t n = net, h = host;
diff --git a/src/network/inet_ntoa.c b/src/network/inet_ntoa.c
new file mode 100644 (file)
index 0000000..71411e0
--- /dev/null
@@ -0,0 +1,10 @@
+#include <arpa/inet.h>
+#include <stdio.h>
+
+char *inet_ntoa(struct in_addr in)
+{
+       static char buf[16];
+       unsigned char *a = (void *)&in;
+       snprintf(buf, sizeof buf, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
+       return buf;
+}