ifcfg-rh: add svFindFirstKeyWithPrefix() function

During backporting manually patched to use GList instead of CList.

(cherry picked from commit e9d960740a)
This commit is contained in:
Thomas Haller 2017-05-25 14:53:03 +02:00
parent 2bf3d590ce
commit 3dfddc18a5
2 changed files with 24 additions and 0 deletions

View file

@ -905,6 +905,28 @@ svGetKeys (shvarFile *s)
/*****************************************************************************/
const char *
svFindFirstKeyWithPrefix (shvarFile *s, const char *key_prefix)
{
const GList *current;
const shvarLine *l;
g_return_val_if_fail (s, NULL);
g_return_val_if_fail (key_prefix, NULL);
for (current = s->lineList; current; current = current->next) {
l = current->data;
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.