From 70e930bc0e7e52ed7f420cea07c40d10387d7cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 30 Jun 2014 13:55:04 +0200 Subject: [PATCH] utils: add nm_utils_is_specific_hostname() The function detects whether the hostname is a specific hostname diferrent from default hostnames like localhost, localhost[6].localdomain[6]. --- src/NetworkManagerUtils.c | 16 +++++++++++++++- src/NetworkManagerUtils.h | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 6b23d76dae..369ae2ca46 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2004 - 2012 Red Hat, Inc. + * Copyright (C) 2004 - 2014 Red Hat, Inc. * Copyright (C) 2005 - 2008 Novell, Inc. */ @@ -1574,3 +1574,17 @@ fail: g_error ("FATAL: Failed asserting path component: %s", name ? name : "(null)"); } +gboolean +nm_utils_is_specific_hostname (const char *name) +{ + if (!name) + return FALSE; + if ( strcmp (name, "(none)") + && strcmp (name, "localhost") + && strcmp (name, "localhost6") + && strcmp (name, "localhost.localdomain") + && strcmp (name, "localhost6.localdomain6")) + return TRUE; + return FALSE; +} + diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index 06143673c6..719a51b726 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2004 - 2011 Red Hat, Inc. + * Copyright (C) 2004 - 2014 Red Hat, Inc. * Copyright (C) 2005 - 2008 Novell, Inc. */ @@ -134,4 +134,6 @@ gint32 nm_utils_get_monotonic_timestamp_s (void); const char *ASSERT_VALID_PATH_COMPONENT (const char *name) G_GNUC_WARN_UNUSED_RESULT; const char *nm_utils_ip6_property_path (const char *ifname, const char *property); +gboolean nm_utils_is_specific_hostname (const char *name); + #endif /* NETWORK_MANAGER_UTILS_H */