ifcfg-rh: add svFindFirstKeyWithPrefix() function

This commit is contained in:
Thomas Haller 2017-05-25 14:53:03 +02:00
parent bdd7d858f3
commit e9d960740a
2 changed files with 24 additions and 0 deletions

View file

@ -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)
{

View file

@ -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.