summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-27 15:11:50 +0200
committerThomas Haller <thaller@redhat.com>2018-05-14 17:53:03 +0200
commit3b0d50475b2e678cbd9a67c063051eeea5f0fe60 (patch)
treeb8190cf338f7495fd8b7317f5238b911efe0e6e6
parentbb649fc3cd2d0dee32241ab603509593335d36bf (diff)
downloadNetworkManager-3b0d50475b2e678cbd9a67c063051eeea5f0fe60.tar.gz
shared: add nm_utils_dbus_path_get_last_component() helper
-rw-r--r--shared/nm-utils/nm-shared-utils.c13
-rw-r--r--shared/nm-utils/nm-shared-utils.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c
index aad1b3ddda..38b99a3ae3 100644
--- a/shared/nm-utils/nm-shared-utils.c
+++ b/shared/nm-utils/nm-shared-utils.c
@@ -549,6 +549,19 @@ nm_cmp_int2ptr_p_with_data (gconstpointer p_a, gconstpointer p_b, gpointer user_
/*****************************************************************************/
+const char *
+nm_utils_dbus_path_get_last_component (const char *dbus_path)
+{
+ if (dbus_path) {
+ dbus_path = strrchr (dbus_path, '/');
+ if (dbus_path)
+ return dbus_path + 1;
+ }
+ return NULL;
+}
+
+/*****************************************************************************/
+
/**
* nm_utils_strsplit_set:
* @str: the string to split.
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h
index cd535097ec..d3d752918a 100644
--- a/shared/nm-utils/nm-shared-utils.h
+++ b/shared/nm-utils/nm-shared-utils.h
@@ -202,6 +202,10 @@ nm_utils_is_separator (const char c)
/*****************************************************************************/
+const char *nm_utils_dbus_path_get_last_component (const char *dbus_path);
+
+/*****************************************************************************/
+
const char **nm_utils_strsplit_set (const char *str, const char *delimiters);
gssize nm_utils_strv_find_first (char **list, gssize len, const char *needle);