summaryrefslogtreecommitdiff
path: root/src/net/dns.c
blob: c39c6abc8d0910a4a20a4cf9aadfc4fb29f67766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef __WIN32__
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <windows.h>
#include <wininet.h>
#endif

#include <string.h>
#include "main.h"

char *dns_resolv(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])));
}