Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions source/inet_ntoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,24 @@ inet_ntoa(struct socket_addr ina)
{
static char buf[4*sizeof "123"];
in_addr_t ia = socket_addr_get_ipv4_addr(&ina);
unsigned char *ucp = (unsigned char *)&ia;

sprintf(buf, "%d.%d.%d.%d",
ucp[0] & 0xff,
ucp[1] & 0xff,
ucp[2] & 0xff,
ucp[3] & 0xff);
sprintf(buf, "%u.%u.%u.%u",
(unsigned)((ia >> 24) & 0xff),
(unsigned)((ia >> 16) & 0xff),
(unsigned)((ia >> 8) & 0xff),
(unsigned)((ia >> 0) & 0xff));
return buf;
}

char *
inet_ntoa_r(struct socket_addr ina, char *buf)
{
in_addr_t ia = socket_addr_get_ipv4_addr(&ina);
unsigned char *ucp = (unsigned char *)&ia;

sprintf(buf, "%d.%d.%d.%d",
ucp[0] & 0xff,
ucp[1] & 0xff,
ucp[2] & 0xff,
ucp[3] & 0xff);
sprintf(buf, "%u.%u.%u.%u",
(unsigned)((ia >> 24) & 0xff),
(unsigned)((ia >> 16) & 0xff),
(unsigned)((ia >> 8) & 0xff),
(unsigned)((ia >> 0) & 0xff));
return buf;
}