commit f5674a2356d4aed5aac239c995eccda06e8e8a75
parent f1e5bc06459af5419931d2a5c90297dd2bb6ed56
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Wed, 10 Apr 2019 15:58:19 -0700
client: Eliminate property_value_options struct
property_value_options is replaced with an array of strings
that represent value options for the properties
Diffstat:
5 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
@@ -187,9 +187,9 @@ done:
return NULL;
}
-static char *proxy_property_completion_value_options(
- const struct property_value_options *options,
- const char *text, int state)
+static char *proxy_property_completion_value_options(const char **options,
+ const char *text,
+ int state)
{
static int index;
static int len;
@@ -200,7 +200,7 @@ static char *proxy_property_completion_value_options(
len = strlen(text);
}
- while ((opt = options[index++].value_str)) {
+ while ((opt = options[index++])) {
if (strncmp(opt, text, len))
continue;
diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
@@ -23,7 +23,6 @@
#include <stdio.h>
struct proxy_interface;
-struct property_value_options;
#define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter"
#define IWD_ACCESS_POINT_INTERFACE "net.connman.iwd.AccessPoint"
@@ -44,7 +43,7 @@ struct proxy_interface_property {
const bool is_read_write;
bool (*append)(struct l_dbus_message_builder *builder,
const char *value_str);
- const struct property_value_options *options;
+ const char **options;
};
struct proxy_interface_type_ops {
diff --git a/client/device.c b/client/device.c
@@ -85,12 +85,7 @@ static void update_name(void *data, struct l_dbus_message_iter *variant)
device->name = l_strdup(value);
}
-static const struct property_value_options device_mode_opts[] = {
- { "ad-hoc", (void *) "ad-hoc" },
- { "ap", (void *) "ap" },
- { "station", (void *) "station" },
- { }
-};
+static const char *device_mode_opts[] = { "ad-hoc", "ap", "station", NULL };
static const char *get_mode(const void *data)
{
diff --git a/client/properties.c b/client/properties.c
@@ -2,7 +2,7 @@
*
* Wireless daemon for Linux
*
- * Copyright (C) 2018 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018-2019 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,20 +28,23 @@
#include "properties.h"
+const char *properties_on_off_opts[3] = { "on", "off", NULL };
+
bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder,
const char *value_str)
{
+ bool value;
+
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);
+ value = true;
+ else if (!strcmp(value_str, "off"))
+ value = false;
+ else
+ return false;
- return false;
+ return l_dbus_message_builder_append_basic(builder, 'b', &value);
}
diff --git a/client/properties.h b/client/properties.h
@@ -20,16 +20,7 @@
*
*/
-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 },
- { }
-};
+const char *properties_on_off_opts[3];
bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder,