3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

client: add variant appender for the on/off properties

This commit is contained in:
Tim Kourt 2018-07-25 12:54:43 -07:00 committed by Denis Kenzior
parent 6ba707fca8
commit 687dcc6145
2 changed files with 33 additions and 0 deletions

View File

@ -28,6 +28,24 @@
#include "properties.h"
bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder,
const char *value_str)
{
if (!builder || !value_str)
return false;
if (!strcmp(value_str, "on"))
return l_dbus_message_builder_append_basic(builder, 'b',
&properties_on_off_opts[0].value);
if (!strcmp(value_str, "off"))
return l_dbus_message_builder_append_basic(builder, 'b',
&properties_on_off_opts[1].value);
return false;
}
bool properties_parse_args(char *args, char **name, char **value)
{
char **arg_arr;

View File

@ -20,4 +20,19 @@
*
*/
struct property_value_options {
const char *value_str;
const void *value;
};
static const struct property_value_options properties_on_off_opts[] = {
{ "on", (void *) true },
{ "off", (void *) false },
{ }
};
bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder,
const char *value_str);
bool properties_parse_args(char *args, char **name, char **value);