2 * This file is part of the sigrok-cli project.
4 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "sigrok-cli.h"
25 static gint sort_inputs(gconstpointer a, gconstpointer b)
27 return strcmp(sr_input_id_get((struct sr_input_module *)a),
28 sr_input_id_get((struct sr_input_module *)b));
31 static gint sort_outputs(gconstpointer a, gconstpointer b)
33 return strcmp(sr_output_id_get((struct sr_output_module *)a),
34 sr_output_id_get((struct sr_output_module *)b));
37 static gint sort_transforms(gconstpointer a, gconstpointer b)
39 return strcmp(sr_transform_id_get((struct sr_transform_module *)a),
40 sr_transform_id_get((struct sr_transform_module *)b));
43 static gint sort_drivers(gconstpointer a, gconstpointer b)
45 const struct sr_dev_driver *sdda = a, *sddb = b;
47 return strcmp(sdda->name, sddb->name);
51 static gint sort_pds(gconstpointer a, gconstpointer b)
53 const struct srd_decoder *sda = a, *sdb = b;
55 return strcmp(sda->id, sdb->id);
59 void show_version(void)
61 struct sr_dev_driver **drivers, *driver;
62 const struct sr_input_module **inputs, *input;
63 const struct sr_output_module **outputs, *output;
64 const struct sr_transform_module **transforms, *transform;
69 struct srd_decoder *dec;
72 printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING);
74 printf("Using libsigrok %s (lib version %s).\n",
75 sr_package_version_string_get(), sr_lib_version_string_get());
77 printf("Using libsigrokdecode %s (lib version %s).\n\n",
78 srd_package_version_string_get(), srd_lib_version_string_get());
81 printf("Supported hardware drivers:\n");
82 drivers = sr_driver_list(sr_ctx);
83 for (sl = NULL, i = 0; drivers[i]; i++)
84 sl = g_slist_append(sl, drivers[i]);
85 sl = g_slist_sort(sl, sort_drivers);
86 for (l = sl; l; l = l->next) {
88 printf(" %-20s %s\n", driver->name, driver->longname);
93 printf("Supported input formats:\n");
94 inputs = sr_input_list();
95 for (sl = NULL, i = 0; inputs[i]; i++)
96 sl = g_slist_append(sl, (gpointer)inputs[i]);
97 sl = g_slist_sort(sl, sort_inputs);
98 for (l = sl; l; l = l->next) {
100 printf(" %-20s %s\n", sr_input_id_get(input),
101 sr_input_description_get(input));
106 printf("Supported output formats:\n");
107 outputs = sr_output_list();
108 for (sl = NULL, i = 0; outputs[i]; i++)
109 sl = g_slist_append(sl, (gpointer)outputs[i]);
110 sl = g_slist_sort(sl, sort_outputs);
111 for (l = sl; l; l = l->next) {
113 printf(" %-20s %s\n", sr_output_id_get(output),
114 sr_output_description_get(output));
119 printf("Supported transform modules:\n");
120 transforms = sr_transform_list();
121 for (sl = NULL, i = 0; transforms[i]; i++)
122 sl = g_slist_append(sl, (gpointer)transforms[i]);
123 sl = g_slist_sort(sl, sort_transforms);
124 for (l = sl; l; l = l->next) {
126 printf(" %-20s %s\n", sr_transform_id_get(transform),
127 sr_transform_description_get(transform));
133 if (srd_init(NULL) == SRD_OK) {
134 printf("Supported protocol decoders:\n");
135 srd_decoder_load_all();
136 sl = g_slist_copy((GSList *)srd_decoder_list());
137 sl = g_slist_sort(sl, sort_pds);
138 for (l = sl; l; l = l->next) {
140 printf(" %-20s %s\n", dec->id, dec->longname);
141 /* Print protocol description upon "-l 3" or higher. */
142 if (opt_loglevel >= SR_LOG_INFO)
143 printf(" %-20s %s\n", "", dec->desc);
152 static gint sort_channels(gconstpointer a, gconstpointer b)
154 const struct sr_channel *pa = a, *pb = b;
156 return pa->index - pb->index;
159 static void print_dev_line(const struct sr_dev_inst *sdi)
161 struct sr_channel *ch;
162 GSList *sl, *l, *channels;
165 struct sr_dev_driver *driver;
166 const char *vendor, *model, *version;
168 driver = sr_dev_inst_driver_get(sdi);
169 vendor = sr_dev_inst_vendor_get(sdi);
170 model = sr_dev_inst_model_get(sdi);
171 version = sr_dev_inst_version_get(sdi);
172 channels = sr_dev_inst_channels_get(sdi);
174 s = g_string_sized_new(128);
175 g_string_assign(s, driver->name);
176 if (maybe_config_get(driver, sdi, NULL, SR_CONF_CONN, &gvar) == SR_OK) {
177 g_string_append(s, ":conn=");
178 g_string_append(s, g_variant_get_string(gvar, NULL));
179 g_variant_unref(gvar);
181 g_string_append(s, " - ");
182 if (vendor && vendor[0])
183 g_string_append_printf(s, "%s ", vendor);
184 if (model && model[0])
185 g_string_append_printf(s, "%s ", model);
186 if (version && version[0])
187 g_string_append_printf(s, "%s ", version);
189 if (g_slist_length(channels) == 1) {
191 g_string_append_printf(s, "with 1 channel: %s", ch->name);
193 sl = g_slist_sort(g_slist_copy(channels), sort_channels);
194 g_string_append_printf(s, "with %d channels:", g_slist_length(sl));
195 for (l = sl; l; l = l->next) {
197 g_string_append_printf(s, " %s", ch->name);
202 g_string_append_printf(s, "\n");
203 printf("%s", s->str);
204 g_string_free(s, TRUE);
208 void show_dev_list(void)
210 struct sr_dev_inst *sdi;
213 if (!(devices = device_scan()))
216 printf("The following devices were found:\n");
217 for (l = devices; l; l = l->next) {
221 g_slist_free(devices);
225 void show_drv_detail(struct sr_dev_driver *driver)
227 const struct sr_key_info *srci;
229 const uint32_t *opts;
230 gsize num_elements, i;
232 if (sr_config_list(driver, NULL, NULL, SR_CONF_DEVICE_OPTIONS,
233 &gvar_opts) == SR_OK) {
234 opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
237 printf("Driver functions:\n");
238 for (i = 0; i < num_elements; i++) {
239 if (!(srci = sr_key_info_get(SR_KEY_CONFIG, opts[i] & SR_CONF_MASK)))
241 printf(" %s\n", srci->name);
244 g_variant_unref(gvar_opts);
247 if (sr_config_list(driver, NULL, NULL, SR_CONF_SCAN_OPTIONS,
248 &gvar_opts) == SR_OK) {
249 opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
252 printf("Scan options:\n");
253 for (i = 0; i < num_elements; i++) {
254 if (!(srci = sr_key_info_get(SR_KEY_CONFIG, opts[i] & SR_CONF_MASK)))
256 printf(" %s\n", srci->id);
259 g_variant_unref(gvar_opts);
263 void show_dev_detail(void)
265 struct sr_dev_driver *driver_from_opt, *driver;
266 struct sr_dev_inst *sdi;
267 const struct sr_key_info *srci, *srmqi, *srmqfi;
268 struct sr_channel *ch;
269 struct sr_channel_group *channel_group, *cg;
270 GSList *devices, *cgl, *chl, *channel_groups;
271 GVariant *gvar_opts, *gvar_dict, *gvar_list, *gvar;
272 gsize num_opts, num_elements;
273 double dlow, dhigh, dcur_low, dcur_high;
274 const uint64_t *uint64, p, q, low, high;
275 uint64_t tmp_uint64, mask, cur_low, cur_high, cur_p, cur_q;
276 const uint32_t *opts;
277 const int32_t *int32;
278 uint32_t key, o, cur_mq, mq;
279 uint64_t cur_mqflags, mqflags;
280 unsigned int num_devices, i, j;
281 char *tmp_str, *s, c;
282 const char **stropts;
284 if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
285 /* A driver was specified, report driver-wide options now. */
286 show_drv_detail(driver_from_opt);
289 if (!(devices = device_scan())) {
290 g_critical("No devices found.");
294 num_devices = g_slist_length(devices);
295 if (num_devices > 1) {
296 g_critical("%d devices found. Use --scan to show them, "
297 "and select one to show.", num_devices);
302 g_slist_free(devices);
305 driver = sr_dev_inst_driver_get(sdi);
306 channel_groups = sr_dev_inst_channel_groups_get(sdi);
308 if (sr_dev_open(sdi) != SR_OK) {
309 g_critical("Failed to open device.");
314 * Selected channels and channel group may affect which options are
315 * returned, or which values for them.
317 select_channels(sdi);
318 channel_group = select_channel_group(sdi);
320 if (sr_config_list(driver, sdi, channel_group, SR_CONF_DEVICE_OPTIONS,
321 &gvar_opts) != SR_OK)
322 /* Driver supports no device instance options. */
325 if (channel_groups) {
326 printf("Channel groups:\n");
327 for (cgl = channel_groups; cgl; cgl = cgl->next) {
329 printf(" %s: channel%s", cg->name,
330 g_slist_length(cg->channels) > 1 ? "s" : "");
331 for (chl = cg->channels; chl; chl = chl->next) {
333 printf(" %s", ch->name);
339 printf("Supported configuration options");
340 if (channel_groups) {
342 printf(" across all channel groups");
344 printf(" on channel group %s", channel_group->name);
347 opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t));
348 for (o = 0; o < num_opts; o++) {
349 key = opts[o] & SR_CONF_MASK;
350 if (!(srci = sr_key_info_get(SR_KEY_CONFIG, key)))
353 if (key == SR_CONF_TRIGGER_MATCH) {
354 if (maybe_config_list(driver, sdi, channel_group, key,
355 &gvar_list) != SR_OK) {
359 int32 = g_variant_get_fixed_array(gvar_list,
360 &num_elements, sizeof(int32_t));
361 printf(" Supported triggers: ");
362 for (i = 0; i < num_elements; i++) {
364 case SR_TRIGGER_ZERO:
370 case SR_TRIGGER_RISING:
373 case SR_TRIGGER_FALLING:
376 case SR_TRIGGER_EDGE:
379 case SR_TRIGGER_OVER:
382 case SR_TRIGGER_UNDER:
393 g_variant_unref(gvar_list);
395 } else if (key == SR_CONF_LIMIT_SAMPLES
396 && config_key_has_cap(driver, sdi, NULL, key, SR_CONF_LIST)) {
398 * If implemented in config_list(), this denotes the
399 * maximum number of samples a device can send. This
400 * really applies only to logic analyzers, and then
401 * only to those that don't support compression, or
402 * have it turned off by default. The values returned
403 * are the low/high limits.
405 if (sr_config_list(driver, sdi, channel_group, key,
407 g_variant_get(gvar, "(tt)", &low, &high);
408 g_variant_unref(gvar);
409 printf(" Maximum number of samples: %"PRIu64"\n", high);
412 } else if (key == SR_CONF_SAMPLERATE) {
413 /* Supported samplerates */
414 printf(" %s", srci->id);
415 if (maybe_config_list(driver, sdi, channel_group, SR_CONF_SAMPLERATE,
416 &gvar_dict) != SR_OK) {
420 if ((gvar_list = g_variant_lookup_value(gvar_dict,
421 "samplerates", G_VARIANT_TYPE("at")))) {
422 uint64 = g_variant_get_fixed_array(gvar_list,
423 &num_elements, sizeof(uint64_t));
424 printf(" - supported samplerates:\n");
425 for (i = 0; i < num_elements; i++) {
426 if (!(s = sr_samplerate_string(uint64[i])))
431 g_variant_unref(gvar_list);
432 } else if ((gvar_list = g_variant_lookup_value(gvar_dict,
433 "samplerate-steps", G_VARIANT_TYPE("at")))) {
434 uint64 = g_variant_get_fixed_array(gvar_list,
435 &num_elements, sizeof(uint64_t));
437 if (!(s = sr_samplerate_string(uint64[0])))
442 if (!(s = sr_samplerate_string(uint64[1])))
447 if (!(s = sr_samplerate_string(uint64[2])))
449 printf(" in steps of %s)\n", s);
451 g_variant_unref(gvar_list);
453 g_variant_unref(gvar_dict);
455 } else if (srci->datatype == SR_T_UINT64) {
456 printf(" %s: ", srci->id);
458 if (maybe_config_get(driver, sdi, channel_group, key,
460 tmp_uint64 = g_variant_get_uint64(gvar);
461 g_variant_unref(gvar);
464 if (maybe_config_list(driver, sdi, channel_group,
465 key, &gvar_list) != SR_OK) {
467 /* Can't list it, but we have a value to show. */
468 printf("%"PRIu64" (current)", tmp_uint64);
473 uint64 = g_variant_get_fixed_array(gvar_list,
474 &num_elements, sizeof(uint64_t));
475 printf(" - supported values:\n");
476 for (i = 0; i < num_elements; i++) {
477 printf(" %"PRIu64, uint64[i]);
478 if (gvar && tmp_uint64 == uint64[i])
479 printf(" (current)");
482 g_variant_unref(gvar_list);
484 } else if (srci->datatype == SR_T_STRING) {
485 printf(" %s: ", srci->id);
486 if (maybe_config_get(driver, sdi, channel_group, key,
488 tmp_str = g_strdup(g_variant_get_string(gvar, NULL));
489 g_variant_unref(gvar);
493 if (maybe_config_list(driver, sdi, channel_group, key,
496 /* Can't list it, but we have a value to show. */
497 printf("%s (current)", tmp_str);
504 stropts = g_variant_get_strv(gvar, &num_elements);
505 for (i = 0; i < num_elements; i++) {
508 printf("%s", stropts[i]);
509 if (tmp_str && !strcmp(tmp_str, stropts[i]))
510 printf(" (current)");
515 g_variant_unref(gvar);
517 } else if (srci->datatype == SR_T_UINT64_RANGE) {
518 printf(" %s: ", srci->id);
519 if (maybe_config_list(driver, sdi, channel_group, key,
520 &gvar_list) != SR_OK) {
525 if (maybe_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) {
526 g_variant_get(gvar, "(tt)", &cur_low, &cur_high);
527 g_variant_unref(gvar);
533 num_elements = g_variant_n_children(gvar_list);
534 for (i = 0; i < num_elements; i++) {
535 gvar = g_variant_get_child_value(gvar_list, i);
536 g_variant_get(gvar, "(tt)", &low, &high);
537 g_variant_unref(gvar);
540 printf("%"PRIu64"-%"PRIu64, low, high);
541 if (low == cur_low && high == cur_high)
542 printf(" (current)");
545 g_variant_unref(gvar_list);
547 } else if (srci->datatype == SR_T_BOOL) {
548 printf(" %s: ", srci->id);
549 if (maybe_config_get(driver, sdi, channel_group, key,
551 if (g_variant_get_boolean(gvar))
552 printf("on (current), off\n");
554 printf("on, off (current)\n");
555 g_variant_unref(gvar);
559 } else if (srci->datatype == SR_T_DOUBLE_RANGE) {
560 printf(" %s: ", srci->id);
561 if (maybe_config_list(driver, sdi, channel_group, key,
562 &gvar_list) != SR_OK) {
567 if (maybe_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) {
568 g_variant_get(gvar, "(dd)", &dcur_low, &dcur_high);
569 g_variant_unref(gvar);
575 num_elements = g_variant_n_children(gvar_list);
576 for (i = 0; i < num_elements; i++) {
577 gvar = g_variant_get_child_value(gvar_list, i);
578 g_variant_get(gvar, "(dd)", &dlow, &dhigh);
579 g_variant_unref(gvar);
582 printf("%.1f-%.1f", dlow, dhigh);
583 if (dlow == dcur_low && dhigh == dcur_high)
584 printf(" (current)");
587 g_variant_unref(gvar_list);
589 } else if (srci->datatype == SR_T_FLOAT) {
590 printf(" %s: ", srci->id);
591 if (maybe_config_get(driver, sdi, channel_group, key,
593 printf("%f\n", g_variant_get_double(gvar));
594 g_variant_unref(gvar);
598 } else if (srci->datatype == SR_T_RATIONAL_PERIOD
599 || srci->datatype == SR_T_RATIONAL_VOLT) {
600 printf(" %s", srci->id);
601 if (maybe_config_get(driver, sdi, channel_group, key,
603 g_variant_get(gvar, "(tt)", &cur_p, &cur_q);
604 g_variant_unref(gvar);
608 if (maybe_config_list(driver, sdi, channel_group,
609 key, &gvar_list) != SR_OK) {
613 printf(" - supported values:\n");
614 num_elements = g_variant_n_children(gvar_list);
615 for (i = 0; i < num_elements; i++) {
616 gvar = g_variant_get_child_value(gvar_list, i);
617 g_variant_get(gvar, "(tt)", &p, &q);
618 if (srci->datatype == SR_T_RATIONAL_PERIOD)
619 s = sr_period_string(p * q);
621 s = sr_voltage_string(p, q);
624 if (p == cur_p && q == cur_q)
625 printf(" (current)");
628 g_variant_unref(gvar_list);
630 } else if (srci->datatype == SR_T_MQ) {
631 printf(" %s: ", srci->id);
632 if (maybe_config_get(driver, sdi, channel_group, key,
634 && g_variant_is_of_type(gvar, G_VARIANT_TYPE_TUPLE)
635 && g_variant_n_children(gvar) == 2) {
636 g_variant_get(gvar, "(ut)", &cur_mq, &cur_mqflags);
637 g_variant_unref(gvar);
639 cur_mq = cur_mqflags = 0;
641 if (maybe_config_list(driver, sdi, channel_group,
642 key, &gvar_list) != SR_OK) {
646 printf(" - supported measurements:\n");
647 num_elements = g_variant_n_children(gvar_list);
648 for (i = 0; i < num_elements; i++) {
650 gvar = g_variant_get_child_value(gvar_list, i);
651 g_variant_get(gvar, "(ut)", &mq, &mqflags);
652 if ((srmqi = sr_key_info_get(SR_KEY_MQ, mq)))
653 printf("%s", srmqi->id);
656 for (j = 0, mask = 1; j < 32; j++, mask <<= 1) {
657 if (!(mqflags & mask))
659 if ((srmqfi = sr_key_info_get(SR_KEY_MQFLAGS, mqflags & mask)))
660 printf("/%s", srmqfi->id);
662 printf("/%" PRIu64, mqflags & mask);
664 if (mq == cur_mq && mqflags == cur_mqflags)
665 printf(" (current)");
668 g_variant_unref(gvar_list);
672 /* Everything else */
673 printf(" %s\n", srci->id);
676 g_variant_unref(gvar_opts);
683 void show_pd_detail(void)
685 struct srd_decoder *dec;
686 struct srd_decoder_option *o;
687 struct srd_channel *pdch;
688 struct srd_decoder_annotation_row *r;
691 char **pdtokens, **pdtok, *optsep, **ann, *val, *doc;
693 pdtokens = g_strsplit(opt_pds, ",", -1);
694 for (pdtok = pdtokens; *pdtok; pdtok++) {
696 if ((optsep = strchr(*pdtok, ':')))
698 if (!(dec = srd_decoder_get_by_id(*pdtok))) {
699 g_critical("Protocol decoder %s not found.", *pdtok);
702 printf("ID: %s\nName: %s\nLong name: %s\nDescription: %s\n",
703 dec->id, dec->name, dec->longname, dec->desc);
704 printf("License: %s\n", dec->license);
705 printf("Annotation classes:\n");
706 if (dec->annotations) {
707 for (l = dec->annotations; l; l = l->next) {
709 printf("- %s: %s\n", ann[0], ann[1]);
714 printf("Annotation rows:\n");
715 if (dec->annotation_rows) {
716 for (l = dec->annotation_rows; l; l = l->next) {
718 printf("- %s (%s): ", r->id, r->desc);
719 for (ll = r->ann_classes; ll; ll = ll->next) {
720 idx = GPOINTER_TO_INT(ll->data);
721 ann = g_slist_nth_data(dec->annotations, idx);
722 printf("%s", ann[0]);
731 printf("Required channels:\n");
733 for (l = dec->channels; l; l = l->next) {
735 printf("- %s (%s): %s\n",
736 pdch->id, pdch->name, pdch->desc);
741 printf("Optional channels:\n");
742 if (dec->opt_channels) {
743 for (l = dec->opt_channels; l; l = l->next) {
745 printf("- %s (%s): %s\n",
746 pdch->id, pdch->name, pdch->desc);
751 printf("Options:\n");
753 for (l = dec->options; l; l = l->next) {
755 printf("- %s: %s (", o->id, o->desc);
756 for (ol = o->values; ol; ol = ol->next) {
757 val = g_variant_print(ol->data, FALSE);
761 val = g_variant_print(o->def, FALSE);
762 printf("default %s)\n", val);
768 if ((doc = srd_decoder_doc_get(dec))) {
769 printf("Documentation:\n%s\n",
770 doc[0] == '\n' ? doc + 1 : doc);
775 g_strfreev(pdtokens);
779 void show_input(void)
781 const struct sr_input_module *imod;
782 const struct sr_option **opts;
787 tok = g_strsplit(opt_input_format, ":", 0);
788 if (!tok[0] || !(imod = sr_input_find(tok[0])))
789 g_critical("Input module '%s' not found.", opt_input_format);
791 printf("ID: %s\nName: %s\n", sr_input_id_get(imod),
792 sr_input_name_get(imod));
793 printf("Description: %s\n", sr_input_description_get(imod));
794 if ((opts = sr_input_options_get(imod))) {
795 printf("Options:\n");
796 for (i = 0; opts[i]; i++) {
797 printf(" %s: %s", opts[i]->id, opts[i]->desc);
799 s = g_variant_print(opts[i]->def, FALSE);
800 printf(" (default %s", s);
802 if (opts[i]->values) {
803 printf(", possible values ");
804 for (l = opts[i]->values; l; l = l->next) {
805 s = g_variant_print((GVariant *)l->data, FALSE);
806 printf("%s%s", s, l->next ? ", " : "");
814 sr_input_options_free(opts);
819 void show_output(void)
821 const struct sr_output_module *omod;
822 const struct sr_option **opts;
827 tok = g_strsplit(opt_output_format, ":", 0);
828 if (!tok[0] || !(omod = sr_output_find(tok[0])))
829 g_critical("Output module '%s' not found.", opt_output_format);
831 printf("ID: %s\nName: %s\n", sr_output_id_get(omod),
832 sr_output_name_get(omod));
833 printf("Description: %s\n", sr_output_description_get(omod));
834 if ((opts = sr_output_options_get(omod))) {
835 printf("Options:\n");
836 for (i = 0; opts[i]; i++) {
837 printf(" %s: %s", opts[i]->id, opts[i]->desc);
839 s = g_variant_print(opts[i]->def, FALSE);
840 printf(" (default %s", s);
842 if (opts[i]->values) {
843 printf(", possible values ");
844 for (l = opts[i]->values; l; l = l->next) {
845 s = g_variant_print((GVariant *)l->data, FALSE);
846 printf("%s%s", s, l->next ? ", " : "");
854 sr_output_options_free(opts);
859 void show_transform(void)
861 const struct sr_transform_module *tmod;
862 const struct sr_option **opts;
867 tok = g_strsplit(opt_transform_module, ":", 0);
868 if (!tok[0] || !(tmod = sr_transform_find(tok[0])))
869 g_critical("Transform module '%s' not found.", opt_transform_module);
871 printf("ID: %s\nName: %s\n", sr_transform_id_get(tmod),
872 sr_transform_name_get(tmod));
873 printf("Description: %s\n", sr_transform_description_get(tmod));
874 if ((opts = sr_transform_options_get(tmod))) {
875 printf("Options:\n");
876 for (i = 0; opts[i]; i++) {
877 printf(" %s: %s", opts[i]->id, opts[i]->desc);
879 s = g_variant_print(opts[i]->def, FALSE);
880 printf(" (default %s", s);
882 if (opts[i]->values) {
883 printf(", possible values ");
884 for (l = opts[i]->values; l; l = l->next) {
885 s = g_variant_print((GVariant *)l->data, FALSE);
886 printf("%s%s", s, l->next ? ", " : "");
894 sr_transform_options_free(opts);