Usermode/libpsockets - Added inet_pton/inet_ntop (stubbed)
authorJohn Hodge <[email protected]>
Sun, 11 Aug 2013 03:13:17 +0000 (11:13 +0800)
committerJohn Hodge <[email protected]>
Sun, 11 Aug 2013 03:13:17 +0000 (11:13 +0800)
Usermode/Libraries/libpsocket.so_src/pton.c [new file with mode: 0644]

diff --git a/Usermode/Libraries/libpsocket.so_src/pton.c b/Usermode/Libraries/libpsocket.so_src/pton.c
new file mode 100644 (file)
index 0000000..581c4f1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Acess2 POSIX Sockets Library
+ * - By John Hodge (thePowersGang)
+ *
+ * pton.c
+ * - inet_pton/inet_ntop
+ */
+#include <netinet/in.h>
+#include <net.h>       // Net_PrintAddress
+#include <acess/sys.h> // _SysDebug
+
+// === CODE ===
+int inet_pton(int af, const char *src, void *dst)
+{
+       _SysDebug("TODO: inet_pton");
+       return -1;
+}
+
+const char *inet_ntop(int af, const void *src, char *dest, size_t len)
+{
+       const char *str = NULL;
+       switch(af)
+       {
+       case AF_INET:
+               str = Net_PrintAddress(4, ((struct in_addr*)src)->s_addr);
+               break;
+       case AF_INET6:
+               str = Net_PrintAddress(6, ((struct in6_addr*)src)->s6_addr);
+               break;
+       default:
+               str = NULL;
+               break;
+       }
+       strncpy(dest, str, len);
+       return dest;
+}
+

UCC git Repository :: git.ucc.asn.au