mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 07:50:16 +01:00
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:
parent
2bf3d590ce
commit
3dfddc18a5
2 changed files with 24 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue