ReactOS 0.4.15-dev-8100-g1887773
inet_ntop.c File Reference

Go to the source code of this file.

Macros

#define IN6ADDRSZ   16
 
#define INT16SZ   2
 
#define SPRINTF(x)   ((socklen_t)sprintf x)
 

Functions

static const charinet_ntop4 (const u_char *src, char *dst, socklen_t size)
 
PCSTR WSAAPI inet_ntop (_In_ INT af, _In_ PVOID src, _Out_writes_(StringBufSize) PSTR dst, _In_ size_t size)
 

Macro Definition Documentation

◆ IN6ADDRSZ

#define IN6ADDRSZ   16

Definition at line 20 of file inet_ntop.c.

◆ INT16SZ

#define INT16SZ   2

Definition at line 24 of file inet_ntop.c.

◆ SPRINTF

#define SPRINTF (   x)    ((socklen_t)sprintf x)

Definition at line 30 of file inet_ntop.c.

Function Documentation

◆ inet_ntop()

PCSTR WSAAPI inet_ntop ( _In_ INT  af,
_In_ PVOID  src,
_Out_writes_(StringBufSize) PSTR  dst,
_In_ size_t  size 
)

Definition at line 54 of file inet_ntop.c.

59{
60
61 switch (af) {
62 case AF_INET:
63 return (inet_ntop4(src, dst, size));
64#ifdef INET6
65 case AF_INET6:
66 return (inet_ntop6(src, dst, size));
67#endif
68 default:
70 return (NULL);
71 }
72 /* NOTREACHED */
73}
#define NULL
Definition: types.h:112
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:123
#define AF_INET
Definition: tcpip.h:117
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define WSAEAFNOSUPPORT
Definition: winerror.h:1960
static const char * inet_ntop4(const u_char *src, char *dst, size_t size)
Definition: inet_ntop.c:86
#define AF_INET6
Definition: winsock.h:369

◆ inet_ntop4()

static const char * inet_ntop4 ( const u_char src,
char dst,
socklen_t  size 
)
static

Definition at line 87 of file inet_ntop.c.

88{
89 static const char fmt[] = "%u.%u.%u.%u";
90 char tmp[sizeof "255.255.255.255"];
91
92 if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
94 return (NULL);
95 }
96 strcpy(dst, tmp);
97 return (dst);
98}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
Definition: dsound.c:943
#define WSAEINVAL
Definition: winerror.h:1946
#define SPRINTF(x)
Definition: inet_ntop.c:32