summaryrefslogtreecommitdiff
path: root/src/net_unix/dns.c
blob: f4036a2ee0234c3a1fa089a34f4268a44841ae7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#include <netdb.h>
#include <string.h>

#include "base/main.h"

char* getIPFormDNS(char *domain)
{
	struct hostent *host;

	host = gethostbyname(domain);

	if( host == NULL ||  host->h_addr_list[0] == NULL )
	{
		return NULL;
	}

	return strdup( inet_ntoa( * ( (struct in_addr *) host->h_addr_list[0] ) ) );
}