SF.net SVN: geany: [2246] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Feb 10 17:53:18 UTC 2008
Revision: 2246
http://geany.svn.sourceforge.net/geany/?rev=2246&view=rev
Author: eht16
Date: 2008-02-10 09:53:18 -0800 (Sun, 10 Feb 2008)
Log Message:
-----------
Add support for getting hostname on Windows.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/utils.c
trunk/src/win32.c
trunk/src/win32.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-02-10 16:46:31 UTC (rev 2245)
+++ trunk/ChangeLog 2008-02-10 17:53:18 UTC (rev 2246)
@@ -12,6 +12,8 @@
time stamp.
Before creating a new socket, delete a maybe existing socket and its
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>
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2008-02-10 16:46:31 UTC (rev 2245)
+++ trunk/src/utils.c 2008-02-10 17:53:18 UTC (rev 2246)
@@ -699,20 +699,14 @@
gchar *utils_get_hostname()
{
-#ifndef HAVE_GETHOSTNAME
- return g_strdup("localhost");
-#else
- gchar *host = g_malloc(25);
- if (gethostname(host, 24) == 0)
- {
- return host;
- }
- else
- {
- g_free(host);
- return g_strdup("localhost");
- }
+#ifdef G_OS_WIN32
+ return win32_get_hostname();
+#elif defined(HAVE_GETHOSTNAME)
+ gchar hostname[100];
+ if (gethostname(hostname, sizeof(hostname)) == 0)
+ return g_strdup(hostname);
#endif
+ return g_strdup("localhost");
}
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2008-02-10 16:46:31 UTC (rev 2245)
+++ trunk/src/win32.c 2008-02-10 17:53:18 UTC (rev 2246)
@@ -700,4 +700,16 @@
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
Modified: trunk/src/win32.h
===================================================================
--- trunk/src/win32.h 2008-02-10 16:46:31 UTC (rev 2245)
+++ trunk/src/win32.h 2008-02-10 17:53:18 UTC (rev 2246)
@@ -59,4 +59,6 @@
gchar *win32_get_appdata_folder();
+gchar *win32_get_hostname();
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list