mirror of
https://github.com/irssi/irssi.git
synced 2025-04-25 12:31:09 -05:00
Merge pull request #1541 from sortie/inet_aton
Replace obsolescent inet_addr(3)/inet_aton(3) with inet_pton(3).
This commit is contained in:
commit
a1c8edfa44
@ -491,8 +491,6 @@ int net_ip2host(IPADDR *ip, char *host)
|
|||||||
|
|
||||||
int net_host2ip(const char *host, IPADDR *ip)
|
int net_host2ip(const char *host, IPADDR *ip)
|
||||||
{
|
{
|
||||||
unsigned long addr;
|
|
||||||
|
|
||||||
if (strchr(host, ':') != NULL) {
|
if (strchr(host, ':') != NULL) {
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
ip->family = AF_INET6;
|
ip->family = AF_INET6;
|
||||||
@ -501,16 +499,8 @@ int net_host2ip(const char *host, IPADDR *ip)
|
|||||||
} else {
|
} else {
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
ip->family = AF_INET;
|
ip->family = AF_INET;
|
||||||
#ifdef HAVE_INET_ATON
|
if (inet_pton(AF_INET, host, &ip->ip) == 0)
|
||||||
if (inet_aton(host, &ip->ip.s_addr) == 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
|
||||||
addr = inet_addr(host);
|
|
||||||
if (addr == INADDR_NONE)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memcpy(&ip->ip, &addr, 4);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user