--- client/main.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/main.c b/client/main.c index 7b24633..1c34269 100644 --- a/client/main.c +++ b/client/main.c @@ -845,6 +845,44 @@ static gboolean check_default_ctrl(void) return TRUE; } +static gboolean parse_argument(const char *arg, const char * const *arg_table, + const char *msg, dbus_bool_t *value, + const char **option) +{ + const char * const *opt; + + if (!arg || !strlen(arg)) { + if (msg) + rl_printf("Missing on/off/%s argument\n", msg); + else + rl_printf("Missing on/off argument\n"); + return FALSE; + } + + if (!strcmp(arg, "on") || !strcmp(arg, "yes")) { + *value = TRUE; + if (option) + *option = ""; + return TRUE; + } + + if (!strcmp(arg, "off") || !strcmp(arg, "no")) { + *value = FALSE; + return TRUE; + } + + for (opt = arg_table; opt && *opt; opt++) { + if (strcmp(arg, *opt) == 0) { + *value = TRUE; + *option = *opt; + return TRUE; + } + } + + rl_printf("Invalid argument %s\n", arg); + return FALSE; +} + static gboolean parse_argument_on_off(const char *arg, dbus_bool_t *value) { if (!arg || !strlen(arg)) { -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html