X-Git-Url: http://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=parsers.c;fp=parsers.c;h=8d654eec5f3804c1ce80958a006610e8ec7def0d;hp=526be7831ecd8afc587a1788cd7179a85ba1d237;hb=41ef1ae49a4973e136ffb99849ad98aa570f9f99;hpb=f553109693c34861f14884b917139bef19d79000 diff --git a/parsers.c b/parsers.c index 526be78..8d654ee 100644 --- a/parsers.c +++ b/parsers.c @@ -294,6 +294,7 @@ GHashTable *generic_arg_to_opt(const struct sr_option **opts, GHashTable *genarg GVariant *gvar; int i; char *s; + gboolean b; hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); @@ -320,6 +321,17 @@ GHashTable *generic_arg_to_opt(const struct sr_option **opts, GHashTable *genarg gvar = g_variant_new_string(s); g_hash_table_insert(hash, g_strdup(opts[i]->id), g_variant_ref_sink(gvar)); + } else if (g_variant_is_of_type(opts[i]->def, G_VARIANT_TYPE_BOOLEAN)) { + b = TRUE; + if (0 == strcmp(s, "false") || 0 == strcmp(s, "no")) { + b = FALSE; + } else if (!(0 == strcmp(s, "true") || 0 == strcmp(s, "yes"))) { + g_critical("Unable to convert '%s' to boolean!", s); + } + + gvar = g_variant_new_boolean(b); + g_hash_table_insert(hash, g_strdup(opts[i]->id), + g_variant_ref_sink(gvar)); } else { g_critical("Don't know GVariant type for option '%s'!", opts[i]->id); }