mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 06:40:18 +01:00
ifcfg-rh: add generic shvar getter and setter for ternary variables
This commit is contained in:
parent
1cf11ccbca
commit
47817a576c
2 changed files with 26 additions and 0 deletions
|
|
@ -1214,6 +1214,20 @@ svGetValueBoolean (shvarFile *s, const char *key, int fallback)
|
|||
return svParseBoolean (value, fallback);
|
||||
}
|
||||
|
||||
/* svGetValueTernary:
|
||||
* @s: fhe file
|
||||
* @key: the name of the key to read
|
||||
*
|
||||
* Reads a value @key and converts it to a NMTernary value.
|
||||
*
|
||||
* Returns: the parsed NMTernary
|
||||
*/
|
||||
NMTernary
|
||||
svGetValueTernary (shvarFile *s, const char *key)
|
||||
{
|
||||
return svGetValueBoolean (s, key, NM_TERNARY_DEFAULT);
|
||||
}
|
||||
|
||||
/* svGetValueInt64:
|
||||
* @s: fhe file
|
||||
* @key: the name of the key to read
|
||||
|
|
@ -1428,6 +1442,15 @@ svSetValueBoolean (shvarFile *s, const char *key, gboolean value)
|
|||
return svSetValue (s, key, value ? "yes" : "no");
|
||||
}
|
||||
|
||||
gboolean
|
||||
svSetValueTernary (shvarFile *s, const char *key, NMTernary value)
|
||||
{
|
||||
if (NM_IN_SET (value, NM_TERNARY_TRUE, NM_TERNARY_FALSE))
|
||||
return svSetValueBoolean (s, key, (gboolean) value);
|
||||
else
|
||||
return svUnsetValue (s, key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
svSetValueBoolean_cond_true (shvarFile *s, const char *key, gboolean value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ const char **svGetKeysSorted (shvarFile *s,
|
|||
*/
|
||||
int svGetValueBoolean (shvarFile *s, const char *key, int def);
|
||||
|
||||
NMTernary svGetValueTernary (shvarFile *s, const char *key);
|
||||
|
||||
gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback);
|
||||
|
||||
gboolean svGetValueEnum (shvarFile *s, const char *key,
|
||||
|
|
@ -84,6 +86,7 @@ gboolean svSetValueBoolean_cond_true (shvarFile *s, const char *key, gboolean va
|
|||
gboolean svSetValueInt64 (shvarFile *s, const char *key, gint64 value);
|
||||
gboolean svSetValueInt64_cond (shvarFile *s, const char *key, gboolean do_set, gint64 value);
|
||||
gboolean svSetValueEnum (shvarFile *s, const char *key, GType gtype, int value);
|
||||
gboolean svSetValueTernary (shvarFile *s, const char *key, NMTernary value);
|
||||
|
||||
gboolean svUnsetValue (shvarFile *s, const char *key);
|
||||
gboolean svUnsetAll (shvarFile *s, SvKeyType match_key_type);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue