Usermode/AxWin4 - (minor) Log and fail when wrong window ID is returned from server
[tpg/acess2.git] / Usermode / Libraries / libpsocket.so_src / pton.c
1 /*
2  * Acess2 POSIX Sockets Library
3  * - By John Hodge (thePowersGang)
4  *
5  * pton.c
6  * - inet_pton/inet_ntop
7  */
8 #include <netinet/in.h>
9 #include <net.h>        // Net_PrintAddress
10 #include <acess/sys.h>  // _SysDebug
11 #include <string.h>
12
13 // === CODE ===
14 int inet_pton(int af, const char *src, void *dst)
15 {
16         _SysDebug("TODO: inet_pton");
17         return -1;
18 }
19
20 const char *inet_ntop(int af, const void *src, char *dest, size_t len)
21 {
22         const char *str = NULL;
23         switch(af)
24         {
25         case AF_INET:
26                 str = Net_PrintAddress(4, &((const struct in_addr*)src)->s_addr);
27                 break;
28         case AF_INET6:
29                 str = Net_PrintAddress(6, &((const struct in6_addr*)src)->s6_addr);
30                 break;
31         default:
32                 str = NULL;
33                 break;
34         }
35         strncpy(dest, str, len);
36         return dest;
37 }
38
39 char *inet_ntoa(struct in_addr in)
40 {
41         return Net_PrintAddress(4, &in.s_addr);
42 }
43

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