diff options
author | Thomas Haller <thaller@redhat.com> | 2018-04-27 15:11:50 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-05-14 17:53:03 +0200 |
commit | 3b0d50475b2e678cbd9a67c063051eeea5f0fe60 (patch) | |
tree | b8190cf338f7495fd8b7317f5238b911efe0e6e6 | |
parent | bb649fc3cd2d0dee32241ab603509593335d36bf (diff) | |
download | NetworkManager-3b0d50475b2e678cbd9a67c063051eeea5f0fe60.tar.gz |
shared: add nm_utils_dbus_path_get_last_component() helper
-rw-r--r-- | shared/nm-utils/nm-shared-utils.c | 13 | ||||
-rw-r--r-- | shared/nm-utils/nm-shared-utils.h | 4 |
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); |