X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/b078de41dfbae96dfb831e6e06df047b669adc4c..42547ed95b693ac08d0770755f87ae123351daec:/windows/winnet.c diff --git a/windows/winnet.c b/windows/winnet.c index c549b087..bcfc004d 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -167,6 +167,7 @@ DECL_WINSOCK_FUNCTION(static, u_long, ntohl, (u_long)); DECL_WINSOCK_FUNCTION(static, u_long, htonl, (u_long)); DECL_WINSOCK_FUNCTION(static, u_short, htons, (u_short)); DECL_WINSOCK_FUNCTION(static, u_short, ntohs, (u_short)); +DECL_WINSOCK_FUNCTION(static, int, gethostname, (char *, int)); DECL_WINSOCK_FUNCTION(static, struct hostent FAR *, gethostbyname, (const char FAR *)); DECL_WINSOCK_FUNCTION(static, struct servent FAR *, getservbyname, @@ -295,6 +296,7 @@ void sk_init(void) GET_WINSOCK_FUNCTION(winsock_module, htonl); GET_WINSOCK_FUNCTION(winsock_module, htons); GET_WINSOCK_FUNCTION(winsock_module, ntohs); + GET_WINSOCK_FUNCTION(winsock_module, gethostname); GET_WINSOCK_FUNCTION(winsock_module, gethostbyname); GET_WINSOCK_FUNCTION(winsock_module, getservbyname); GET_WINSOCK_FUNCTION(winsock_module, inet_addr); @@ -1684,6 +1686,22 @@ int net_service_lookup(char *service) return 0; } +char *get_hostname(void) +{ + int len = 128; + char *hostname = NULL; + do { + len *= 2; + hostname = sresize(hostname, len, char); + if (p_gethostname(hostname, len) < 0) { + sfree(hostname); + hostname = NULL; + break; + } + } while (strlen(hostname) >= len-1); + return hostname; +} + SockAddr platform_get_x11_unix_address(const char *display, int displaynum, char **canonicalname) {