From 7b8185bc1533239b5afd185ae780807123ffef1a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 11 Aug 2013 11:13:17 +0800 Subject: [PATCH] Usermode/libpsockets - Added inet_pton/inet_ntop (stubbed) --- Usermode/Libraries/libpsocket.so_src/pton.c | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Usermode/Libraries/libpsocket.so_src/pton.c diff --git a/Usermode/Libraries/libpsocket.so_src/pton.c b/Usermode/Libraries/libpsocket.so_src/pton.c new file mode 100644 index 00000000..581c4f1c --- /dev/null +++ b/Usermode/Libraries/libpsocket.so_src/pton.c @@ -0,0 +1,37 @@ +/* + * Acess2 POSIX Sockets Library + * - By John Hodge (thePowersGang) + * + * pton.c + * - inet_pton/inet_ntop + */ +#include +#include // Net_PrintAddress +#include // _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; +} + -- 2.20.1