diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-25 14:53:03 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-30 11:10:19 +0200 |
commit | e9d960740af008acb91074b31a570fba17dc0344 (patch) | |
tree | 23ed9e6824051469289b6aae0d7231810f3369f3 | |
parent | bdd7d858f3114b6f71875efa97f2d537613c33db (diff) | |
download | NetworkManager-e9d960740af008acb91074b31a570fba17dc0344.tar.gz |
ifcfg-rh: add svFindFirstKeyWithPrefix() function
-rw-r--r-- | src/settings/plugins/ifcfg-rh/shvar.c | 22 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/shvar.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 365e240bf4..67b1a9afa5 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -891,6 +891,28 @@ svGetKeys (shvarFile *s) /*****************************************************************************/ +const char * +svFindFirstKeyWithPrefix (shvarFile *s, const char *key_prefix) +{ + CList *current; + const shvarLine *l; + + g_return_val_if_fail (s, NULL); + g_return_val_if_fail (key_prefix, NULL); + + c_list_for_each (current, &s->lst_head) { + l = c_list_entry (current, shvarLine, lst); + if ( l->key + && l->line + && g_str_has_prefix (l->key, key_prefix)) + return l->key; + } + + return NULL; +} + +/*****************************************************************************/ + static const char * _svGetValue (shvarFile *s, const char *key, char **to_free) { diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index e9519d287b..1904ed256d 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -44,6 +44,8 @@ shvarFile *svCreateFile (const char *name); /* Open the file <name>, return shvarFile on success, NULL on failure */ shvarFile *svOpenFile (const char *name, GError **error); +const char *svFindFirstKeyWithPrefix (shvarFile *s, const char *key_prefix); + /* Get the value associated with the key, and leave the current pointer * pointing at the line containing the value. The char* returned MUST * be freed by the caller. |