Since r8305, Unix PuTTY has always "upgraded" an X11 display like "localhost:0"
[sgt/putty] / unix / uxnet.c
index 8e95a65..4467d08 100644 (file)
@@ -1395,6 +1395,23 @@ 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 ((gethostname(hostname, len) < 0) &&
+           (errno != ENAMETOOLONG)) {
+           sfree(hostname);
+           hostname = NULL;
+           break;
+       }
+    } while (strlen(hostname) >= len-1);
+    return hostname;
+}
+
 SockAddr platform_get_x11_unix_address(const char *sockpath, int displaynum)
 {
     SockAddr ret = snew(struct SockAddr_tag);