Commit ed947fd0 authored by Jussi Laakkonen's avatar Jussi Laakkonen

vpn-config: Implement function to get boolean from keyfile

[vpn-config] Implement function to get boolean from keyfile. JB#45606

Simple boolean getter for VPN keyfiles. In case of error (key missing or
invalid boolean) the default value given is returned.
parent 826942c3
......@@ -574,3 +574,15 @@ char **__vpn_config_get_string_list(GKeyFile *key_file,
return strlist;
}
bool __vpn_config_get_boolean(GKeyFile *key_file, const char *group_name,
const char *key, GError **error, bool default_value)
{
bool val;
val = g_key_file_get_boolean(key_file, group_name, key, error);
if (error)
return default_value;
return val;
}
......@@ -114,10 +114,12 @@ int __vpn_rtnl_send(const void *buf, size_t len);
int __vpn_config_init(void);
void __vpn_config_cleanup(void);
char *__vpn_config_get_string(GKeyFile *key_file,
const char *group_name, const char *key, GError **error);
char **__vpn_config_get_string_list(GKeyFile *key_file,
const char *group_name, const char *key, gsize *length, GError **error);
char *__vpn_config_get_string(GKeyFile *key_file, const char *group_name,
const char *key, GError **error);
char **__vpn_config_get_string_list(GKeyFile *key_file, const char *group_name,
const char *key, gsize *length, GError **error);
bool __vpn_config_get_boolean(GKeyFile *key_file, const char *group_name,
const char *key, GError **error, bool default_value);
#ifndef VPN_STATEDIR
#define VPN_STATEDIR vpn_settings_get_state_dir()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment