[glibmm: 1/2] Add Glib::get_host_name()



commit 3c8666f81441eb3627cfb1dca257295331813392
Author: scx <scx mail gmail com>
Date:   Mon Sep 23 00:58:31 2019 +0200

    Add Glib::get_host_name()
    
    Wraps g_get_host_name() from glib.
    Return a name for the machine.
    
    Closes GNOME/glibmm#58

 glib/src/miscutils.ccg |  6 ++++++
 glib/src/miscutils.hg  | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)
---
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
@@ -92,6 +92,12 @@ get_real_name()
   return convert_const_gchar_ptr_to_stdstring(g_get_real_name());
 }
 
+std::string
+get_host_name()
+{
+  return convert_const_gchar_ptr_to_stdstring(g_get_host_name());
+}
+
 std::string
 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.
  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]