X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=main.c;h=e4d321b51b0d8faa1a818ffae36586db2f9675c3;hp=17065101af2bfcbe96ec75e36eabd91d98e532ab;hb=198182cc092b56a005e8990057bffb99794ec797;hpb=e4e4b4724b27addf14b827314104295e4125396a diff --git a/main.c b/main.c index 1706510..e4d321b 100644 --- a/main.c +++ b/main.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include "sigrok-cli.h" @@ -73,40 +74,11 @@ int select_channels(struct sr_dev_inst *sdi) return SR_OK; } -gboolean config_key_has_cap(struct sr_dev_driver *driver, - const struct sr_dev_inst *sdi, struct sr_channel_group *cg, - uint32_t key, uint32_t capability) -{ - GVariant *gvar_opts; - const uint32_t *opts; - gsize num_opts, i; - gboolean result; - - if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, - &gvar_opts) != SR_OK) - return FALSE; - - opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t)); - result = FALSE; - for (i = 0; i < num_opts; i++) { - if ((opts[i] & SR_CONF_MASK) == key) { - if ((opts[i] & capability) == capability) - result = TRUE; - else - result = FALSE; - break; - } - } - g_variant_unref(gvar_opts); - - return result; -} - int maybe_config_get(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant **gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_GET)) + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_GET) return sr_config_get(driver, sdi, cg, key, gvar); return SR_ERR_NA; @@ -116,7 +88,9 @@ int maybe_config_set(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant *gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_SET)) + (void)driver; + + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_SET) return sr_config_set(sdi, cg, key, gvar); return SR_ERR_NA; @@ -126,7 +100,7 @@ int maybe_config_list(struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, struct sr_channel_group *cg, uint32_t key, GVariant **gvar) { - if (config_key_has_cap(driver, sdi, cg, key, SR_CONF_LIST)) + if (sr_dev_config_capabilities_list(sdi, cg, key) & SR_CONF_LIST) return sr_config_list(driver, sdi, cg, key, gvar); return SR_ERR_NA; @@ -240,8 +214,6 @@ int main(int argc, char **argv) } if (register_pds(opt_pds, opt_pd_annotations) != 0) goto done; - if (setup_pd_stack(opt_pds, opt_pd_stack, opt_pd_annotations) != 0) - goto done; /* Only one output type is ever shown. */ if (opt_pd_binary) { @@ -269,6 +241,8 @@ int main(int argc, char **argv) if (opt_version) show_version(); + else if (opt_list_supported) + show_supported(); else if (opt_input_format && opt_show) show_input(); else if (opt_output_format && opt_show)