Add support for getting hostname on Windows.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2246 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
6cd65c7f59
commit
d60378dd98
@ -12,6 +12,8 @@
|
|||||||
time stamp.
|
time stamp.
|
||||||
Before creating a new socket, delete a maybe existing socket and its
|
Before creating a new socket, delete a maybe existing socket and its
|
||||||
symlink.
|
symlink.
|
||||||
|
* src/utils.c, src/win32.c, src/win32.h:
|
||||||
|
Add support for getting hostname on Windows.
|
||||||
|
|
||||||
|
|
||||||
2008-02-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
2008-02-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
20
src/utils.c
20
src/utils.c
@ -699,20 +699,14 @@ gchar utils_brace_opposite(gchar ch)
|
|||||||
|
|
||||||
gchar *utils_get_hostname()
|
gchar *utils_get_hostname()
|
||||||
{
|
{
|
||||||
#ifndef HAVE_GETHOSTNAME
|
#ifdef G_OS_WIN32
|
||||||
return g_strdup("localhost");
|
return win32_get_hostname();
|
||||||
#else
|
#elif defined(HAVE_GETHOSTNAME)
|
||||||
gchar *host = g_malloc(25);
|
gchar hostname[100];
|
||||||
if (gethostname(host, 24) == 0)
|
if (gethostname(hostname, sizeof(hostname)) == 0)
|
||||||
{
|
return g_strdup(hostname);
|
||||||
return host;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_free(host);
|
|
||||||
return g_strdup("localhost");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
return g_strdup("localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
12
src/win32.c
12
src/win32.c
@ -700,4 +700,16 @@ gchar *win32_get_appdata_folder()
|
|||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gchar *win32_get_hostname()
|
||||||
|
{
|
||||||
|
gchar hostname[100];
|
||||||
|
DWORD size = sizeof(hostname);
|
||||||
|
|
||||||
|
if (GetComputerName(hostname, &size))
|
||||||
|
return g_strdup(hostname);
|
||||||
|
else
|
||||||
|
return g_strdup("localhost");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,4 +59,6 @@ void win32_init_debug_code();
|
|||||||
|
|
||||||
gchar *win32_get_appdata_folder();
|
gchar *win32_get_appdata_folder();
|
||||||
|
|
||||||
|
gchar *win32_get_hostname();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user