X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=device.c;h=a7dfe62d57166a08eb40aae5fc81e8f43f6d5eba;hp=2dc830817df44c4eab739421a275b269e4a73a1b;hb=02c659351bda97f77922356f48a7eed1d3137011;hpb=2be182e6437fb082aedca653fdc106d702518db0 diff --git a/device.c b/device.c index 2dc8308..a7dfe62 100644 --- a/device.c +++ b/device.c @@ -17,10 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#include "sigrok-cli.h" extern struct sr_context *sr_ctx; extern gchar *opt_drv; @@ -29,24 +28,18 @@ extern gchar *opt_probe_group; /* Convert driver options hash to GSList of struct sr_config. */ static GSList *hash_to_hwopt(GHashTable *hash) { - const struct sr_config_info *srci; struct sr_config *src; GList *gl, *keys; GSList *opts; - char *key, *value; + char *key; keys = g_hash_table_get_keys(hash); opts = NULL; for (gl = keys; gl; gl = gl->next) { key = gl->data; - if (!(srci = sr_config_info_name_get(key))) { - g_critical("Unknown option %s", key); + src = g_malloc(sizeof(struct sr_config)); + if (opt_to_gvar(key, g_hash_table_lookup(hash, key), src) != 0) return NULL; - } - src = g_try_malloc(sizeof(struct sr_config)); - src->key = srci->key; - value = g_hash_table_lookup(hash, key); - src->data = g_variant_new_string(value); opts = g_slist_append(opts, src); } g_list_free(keys);