mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01:00
ifcfg-rh: add svGetValueFull() function
This commit is contained in:
parent
32871deecc
commit
33aaa730c5
2 changed files with 18 additions and 6 deletions
|
|
@ -256,6 +256,22 @@ svEscape (const char *s, char **to_free)
|
|||
*/
|
||||
char *
|
||||
svGetValue (shvarFile *s, const char *key, gboolean verbatim)
|
||||
{
|
||||
char *value;
|
||||
|
||||
value = svGetValueFull (s, key, verbatim);
|
||||
if (value && !*value) {
|
||||
g_free (value);
|
||||
return NULL;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* svGetValueFull() is identical to svGetValue() except that
|
||||
* svGetValue() will never return an empty value (but %NULL instead).
|
||||
* svGetValueFull() will return empty values if that is the value for the @key. */
|
||||
char *
|
||||
svGetValueFull (shvarFile *s, const char *key, gboolean verbatim)
|
||||
{
|
||||
char *value = NULL;
|
||||
char *line;
|
||||
|
|
@ -280,12 +296,7 @@ svGetValue (shvarFile *s, const char *key, gboolean verbatim)
|
|||
}
|
||||
g_free (keyString);
|
||||
|
||||
if (value && value[0]) {
|
||||
return value;
|
||||
} else {
|
||||
g_free (value);
|
||||
return NULL;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* return TRUE if <key> resolves to any truth value (e.g. "yes", "y", "true")
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ shvarFile *svOpenFile (const char *name, GError **error);
|
|||
* be freed by the caller.
|
||||
*/
|
||||
char *svGetValue (shvarFile *s, const char *key, gboolean verbatim);
|
||||
char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim);
|
||||
|
||||
/* return TRUE if <key> resolves to any truth value (e.g. "yes", "y", "true")
|
||||
* return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue