summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-20 13:42:05 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-21 16:22:26 +0200
commit09239d9b11483c8fcc71e7f76a2f5f83ae1b4473 (patch)
tree2e6d33b101fdb68a53d58e495edec03c5814ae77 /client
parentc27864e1c53eeddb5271eab60b4fa92e7938f837 (diff)
downloadconnman-09239d9b11483c8fcc71e7f76a2f5f83ae1b4473.tar.gz
connman-09239d9b11483c8fcc71e7f76a2f5f83ae1b4473.tar.bz2
connman-09239d9b11483c8fcc71e7f76a2f5f83ae1b4473.zip
client: Add boolean parsing helper function
Diffstat (limited to 'client')
-rw-r--r--client/services.c26
-rw-r--r--client/services.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/client/services.c b/client/services.c
index 7e6424f5..a5450006 100644
--- a/client/services.c
+++ b/client/services.c
@@ -36,6 +36,32 @@
#include "services.h"
#include "dbus.h"
+int parse_boolean(char *arg)
+{
+ if (arg == NULL)
+ return -1;
+
+ if (strcasecmp(arg, "no") == 0 ||
+ strcasecmp(arg, "false") == 0 ||
+ strcasecmp(arg, "off" ) == 0 ||
+ strcasecmp(arg, "disable" ) == 0 ||
+ strcasecmp(arg, "n") == 0 ||
+ strcasecmp(arg, "f") == 0 ||
+ strcasecmp(arg, "0") == 0)
+ return 0;
+
+ if (strcasecmp(arg, "yes") == 0 ||
+ strcasecmp(arg, "true") == 0 ||
+ strcasecmp(arg, "on") == 0 ||
+ strcasecmp(arg, "enable" ) == 0 ||
+ strcasecmp(arg, "y") == 0 ||
+ strcasecmp(arg, "t") == 0 ||
+ strcasecmp(arg, "1") == 0)
+ return 1;
+
+ return -1;
+}
+
static void append_property_array(DBusMessageIter *iter, char *property,
char **data, int num_args)
{
diff --git a/client/services.h b/client/services.h
index eccc60a6..09ed2c08 100644
--- a/client/services.h
+++ b/client/services.h
@@ -33,6 +33,7 @@ struct service_data {
dbus_bool_t online;
};
+int parse_boolean(char *arg);
char *strip_service_path(char *service);
void extract_service_name(DBusMessageIter *dict, struct service_data *service);
int set_service_property(DBusConnection *connection, DBusMessage *message,