GUI-FreeRDP/address.c

29 lines
511 B
C
Raw Normal View History

/*
* address.c
*
* Created on: 15 июл. 2022 г.
* Author: alexander
*/
#include "address.h"
#include <netdb.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
char *getHostIP(char *dnsName)
{
char *result = NULL;
struct hostent *he = gethostbyname(dnsName);
if (he)
{
char *ip = inet_ntoa(*(struct in_addr*)he->h_addr);
result = (char *)malloc(sizeof(char) * strlen(ip));
strcpy(result, ip);
}
return result;
}