summaryrefslogtreecommitdiff
path: root/glib/src
diff options
context:
space:
mode:
authorscx <scx.mail@gmail.com>2019-09-23 00:58:31 +0200
committerscx <scx.mail@gmail.com>2019-09-23 00:58:31 +0200
commit3c8666f81441eb3627cfb1dca257295331813392 (patch)
treeffafffcd8c0a8aafe5545597336dfab09c9a04d5 /glib/src
parent29aca85ded91c8f56bad6d4a830b752e680c4e89 (diff)
downloadglibmm-3c8666f81441eb3627cfb1dca257295331813392.tar.gz
Add Glib::get_host_name()
Wraps g_get_host_name() from glib. Return a name for the machine. Closes GNOME/glibmm#58
Diffstat (limited to 'glib/src')
-rw-r--r--glib/src/miscutils.ccg6
-rw-r--r--glib/src/miscutils.hg19
2 files changed, 25 insertions, 0 deletions
diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg
index 90043aff..5e002349 100644
--- a/glib/src/miscutils.ccg
+++ b/glib/src/miscutils.ccg
@@ -93,6 +93,12 @@ get_real_name()
}
std::string
+get_host_name()
+{
+ return convert_const_gchar_ptr_to_stdstring(g_get_host_name());
+}
+
+std::string
get_home_dir()
{
return convert_const_gchar_ptr_to_stdstring(g_get_home_dir());
diff --git a/glib/src/miscutils.hg b/glib/src/miscutils.hg
index ffc87f31..932f6c85 100644
--- a/glib/src/miscutils.hg
+++ b/glib/src/miscutils.hg
@@ -163,6 +163,25 @@ std::string get_user_name();
*/
std::string get_real_name();
+/** Return a name for the machine.
+ *
+ * The returned name is not necessarily a fully-qualified domain name,
+ * or even present in DNS or some other name service at all. It need
+ * not even be unique on your local network or site, but usually it
+ * is. Callers should not rely on the return value having any specific
+ * properties like uniqueness for security purposes. Even if the name
+ * of the machine is changed while an application is running, the
+ * return value from this function does not change. The returned
+ * string is owned by GLib and should not be modified or freed. If no
+ * name can be determined, a default fixed string "localhost" is
+ * returned.
+ *
+ * @return The host name of the machine.
+ *
+ * @newin{2,64}
+ */
+std::string get_host_name();
+
/** Gets the current user's home directory.
* @return The current user's home directory or an empty string if not defined.
*/