GUI-FreeRDP/address.c

30 lines
550 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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);
size_t size = strlen(ip) + 1;
result = (char *)malloc(sizeof(char) * size);
strncpy(result, ip, size);
}
return result;
}