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/>.
20 #include "sigrok-cli.h"
24 static gint
sort_inputs(gconstpointer a
, gconstpointer b
)
26 return strcmp(sr_input_id_get((struct sr_input_module
*)a
),
27 sr_input_id_get((struct sr_input_module
*)b
));
30 static gint
sort_outputs(gconstpointer a
, gconstpointer b
)
32 return strcmp(sr_output_id_get((struct sr_output_module
*)a
),
33 sr_output_id_get((struct sr_output_module
*)b
));
36 static gint
sort_transforms(gconstpointer a
, gconstpointer b
)
38 return strcmp(sr_transform_id_get((struct sr_transform_module
*)a
),
39 sr_transform_id_get((struct sr_transform_module
*)b
));
42 static gint
sort_drivers(gconstpointer a
, gconstpointer b
)
44 const struct sr_dev_driver
*sdda
= a
, *sddb
= b
;
46 return strcmp(sdda
->name
, sddb
->name
);
50 static gint
sort_pds(gconstpointer a
, gconstpointer b
)
52 const struct srd_decoder
*sda
= a
, *sdb
= b
;
54 return strcmp(sda
->id
, sdb
->id
);
58 void show_version(void)
60 struct sr_dev_driver
**drivers
, *driver
;
61 const struct sr_input_module
**inputs
, *input
;
62 const struct sr_output_module
**outputs
, *output
;
63 const struct sr_transform_module
**transforms
, *transform
;
68 struct srd_decoder
*dec
;
71 printf("sigrok-cli %s\n\n", VERSION
);
73 printf("Using libsigrok %s (lib version %s).\n",
74 sr_package_version_string_get(), sr_lib_version_string_get());
76 printf("Using libsigrokdecode %s (lib version %s).\n\n",
77 srd_package_version_string_get(), srd_lib_version_string_get());
80 printf("Supported hardware drivers:\n");
81 drivers
= sr_driver_list();
82 for (sl
= NULL
, i
= 0; drivers
[i
]; i
++)
83 sl
= g_slist_append(sl
, drivers
[i
]);
84 sl
= g_slist_sort(sl
, sort_drivers
);
85 for (l
= sl
; l
; l
= l
->next
) {
87 printf(" %-20s %s\n", driver
->name
, driver
->longname
);
92 printf("Supported input formats:\n");
93 inputs
= sr_input_list();
94 for (sl
= NULL
, i
= 0; inputs
[i
]; i
++)
95 sl
= g_slist_append(sl
, (gpointer
)inputs
[i
]);
96 sl
= g_slist_sort(sl
, sort_inputs
);
97 for (l
= sl
; l
; l
= l
->next
) {
99 printf(" %-20s %s\n", sr_input_id_get(input
),
100 sr_input_description_get(input
));
105 printf("Supported output formats:\n");
106 outputs
= sr_output_list();
107 for (sl
= NULL
, i
= 0; outputs
[i
]; i
++)
108 sl
= g_slist_append(sl
, (gpointer
)outputs
[i
]);
109 sl
= g_slist_sort(sl
, sort_outputs
);
110 for (l
= sl
; l
; l
= l
->next
) {
112 printf(" %-20s %s\n", sr_output_id_get(output
),
113 sr_output_description_get(output
));
118 printf("Supported transform modules:\n");
119 transforms
= sr_transform_list();
120 for (sl
= NULL
, i
= 0; transforms
[i
]; i
++)
121 sl
= g_slist_append(sl
, (gpointer
)transforms
[i
]);
122 sl
= g_slist_sort(sl
, sort_transforms
);
123 for (l
= sl
; l
; l
= l
->next
) {
125 printf(" %-20s %s\n", sr_transform_id_get(transform
),
126 sr_transform_description_get(transform
));
132 if (srd_init(NULL
) == SRD_OK
) {
133 printf("Supported protocol decoders:\n");
134 srd_decoder_load_all();
135 sl
= g_slist_copy((GSList
*)srd_decoder_list());
136 sl
= g_slist_sort(sl
, sort_pds
);
137 for (l
= sl
; l
; l
= l
->next
) {
139 printf(" %-20s %s\n", dec
->id
, dec
->longname
);
140 /* Print protocol description upon "-l 3" or higher. */
141 if (opt_loglevel
>= SR_LOG_INFO
)
142 printf(" %-20s %s\n", "", dec
->desc
);
151 static gint
sort_channels(gconstpointer a
, gconstpointer b
)
153 const struct sr_channel
*pa
= a
, *pb
= b
;
155 return pa
->index
- pb
->index
;
158 static void print_dev_line(const struct sr_dev_inst
*sdi
)
160 struct sr_channel
*ch
;
161 GSList
*sl
, *l
, *channels
;
164 struct sr_dev_driver
*driver
;
165 const char *vendor
, *model
, *version
;
167 driver
= sr_dev_inst_driver_get(sdi
);
168 vendor
= sr_dev_inst_vendor_get(sdi
);
169 model
= sr_dev_inst_model_get(sdi
);
170 version
= sr_dev_inst_version_get(sdi
);
171 channels
= sr_dev_inst_channels_get(sdi
);
173 s
= g_string_sized_new(128);
174 g_string_assign(s
, driver
->name
);
175 if (maybe_config_get(driver
, sdi
, NULL
, SR_CONF_CONN
, &gvar
) == SR_OK
) {
176 g_string_append(s
, ":conn=");
177 g_string_append(s
, g_variant_get_string(gvar
, NULL
));
178 g_variant_unref(gvar
);
180 g_string_append(s
, " - ");
181 if (vendor
&& vendor
[0])
182 g_string_append_printf(s
, "%s ", vendor
);
183 if (model
&& model
[0])
184 g_string_append_printf(s
, "%s ", model
);
185 if (version
&& version
[0])
186 g_string_append_printf(s
, "%s ", version
);
188 if (g_slist_length(channels
) == 1) {
190 g_string_append_printf(s
, "with 1 channel: %s", ch
->name
);
192 sl
= g_slist_sort(g_slist_copy(channels
), sort_channels
);
193 g_string_append_printf(s
, "with %d channels:", g_slist_length(sl
));
194 for (l
= sl
; l
; l
= l
->next
) {
196 g_string_append_printf(s
, " %s", ch
->name
);
201 g_string_append_printf(s
, "\n");
202 printf("%s", s
->str
);
203 g_string_free(s
, TRUE
);
207 void show_dev_list(void)
209 struct sr_dev_inst
*sdi
;
212 if (!(devices
= device_scan()))
215 printf("The following devices were found:\n");
216 for (l
= devices
; l
; l
= l
->next
) {
220 g_slist_free(devices
);
224 void show_drv_detail(struct sr_dev_driver
*driver
)
226 const struct sr_config_info
*srci
;
228 const uint32_t *opts
;
229 gsize num_elements
, i
;
231 if (sr_config_list(driver
, NULL
, NULL
, SR_CONF_DEVICE_OPTIONS
,
232 &gvar_opts
) == SR_OK
) {
233 opts
= g_variant_get_fixed_array(gvar_opts
, &num_elements
,
236 printf("Driver functions:\n");
237 for (i
= 0; i
< num_elements
; i
++) {
238 if (!(srci
= sr_config_info_get(opts
[i
] & SR_CONF_MASK
)))
240 printf(" %s\n", srci
->name
);
243 g_variant_unref(gvar_opts
);
246 if (sr_config_list(driver
, NULL
, NULL
, SR_CONF_SCAN_OPTIONS
,
247 &gvar_opts
) == SR_OK
) {
248 opts
= g_variant_get_fixed_array(gvar_opts
, &num_elements
,
251 printf("Scan options:\n");
252 for (i
= 0; i
< num_elements
; i
++) {
253 if (!(srci
= sr_config_info_get(opts
[i
] & SR_CONF_MASK
)))
255 printf(" %s\n", srci
->id
);
258 g_variant_unref(gvar_opts
);
262 void show_dev_detail(void)
264 struct sr_dev_driver
*driver_from_opt
, *driver
;
265 struct sr_dev_inst
*sdi
;
266 const struct sr_config_info
*srci
;
267 struct sr_channel
*ch
;
268 struct sr_channel_group
*channel_group
, *cg
;
269 GSList
*devices
, *cgl
, *chl
, *channel_groups
;
270 GVariant
*gvar_opts
, *gvar_dict
, *gvar_list
, *gvar
;
271 gsize num_opts
, num_elements
;
272 double dlow
, dhigh
, dcur_low
, dcur_high
;
273 const uint64_t *uint64
, p
, q
, low
, high
;
274 uint64_t tmp_uint64
, cur_low
, cur_high
, cur_p
, cur_q
;
275 const uint32_t *opts
;
276 const int32_t *int32
;
278 unsigned int num_devices
, i
;
279 char *tmp_str
, *s
, c
;
280 const char **stropts
;
282 if (parse_driver(opt_drv
, &driver_from_opt
, NULL
)) {
283 /* A driver was specified, report driver-wide options now. */
284 show_drv_detail(driver_from_opt
);
287 if (!(devices
= device_scan())) {
288 g_critical("No devices found.");
292 num_devices
= g_slist_length(devices
);
293 if (num_devices
> 1) {
294 g_critical("%d devices found. Use --scan to show them, "
295 "and select one to show.", num_devices
);
300 g_slist_free(devices
);
303 driver
= sr_dev_inst_driver_get(sdi
);
304 channel_groups
= sr_dev_inst_channel_groups_get(sdi
);
306 if (sr_dev_open(sdi
) != SR_OK
) {
307 g_critical("Failed to open device.");
311 /* Selected channels and channel group may affect which options are
312 * returned, or which values for them. */
313 select_channels(sdi
);
314 channel_group
= select_channel_group(sdi
);
316 if (sr_config_list(driver
, sdi
, channel_group
, SR_CONF_DEVICE_OPTIONS
,
317 &gvar_opts
) != SR_OK
)
318 /* Driver supports no device instance options. */
321 if (channel_groups
) {
322 printf("Channel groups:\n");
323 for (cgl
= channel_groups
; cgl
; cgl
= cgl
->next
) {
325 printf(" %s: channel%s", cg
->name
,
326 g_slist_length(cg
->channels
) > 1 ? "s" : "");
327 for (chl
= cg
->channels
; chl
; chl
= chl
->next
) {
329 printf(" %s", ch
->name
);
335 printf("Supported configuration options");
336 if (channel_groups
) {
338 printf(" across all channel groups");
340 printf(" on channel group %s", channel_group
->name
);
343 opts
= g_variant_get_fixed_array(gvar_opts
, &num_opts
, sizeof(uint32_t));
344 for (o
= 0; o
< num_opts
; o
++) {
345 key
= opts
[o
] & SR_CONF_MASK
;
346 if (!(srci
= sr_config_info_get(key
)))
349 if (key
== SR_CONF_TRIGGER_MATCH
) {
350 if (maybe_config_list(driver
, sdi
, channel_group
, key
,
351 &gvar_list
) != SR_OK
) {
355 int32
= g_variant_get_fixed_array(gvar_list
,
356 &num_elements
, sizeof(int32_t));
357 printf(" Supported triggers: ");
358 for (i
= 0; i
< num_elements
; i
++) {
360 case SR_TRIGGER_ZERO
:
366 case SR_TRIGGER_RISING
:
369 case SR_TRIGGER_FALLING
:
372 case SR_TRIGGER_EDGE
:
375 case SR_TRIGGER_OVER
:
378 case SR_TRIGGER_UNDER
:
389 g_variant_unref(gvar_list
);
391 } else if (key
== SR_CONF_LIMIT_SAMPLES
392 && config_key_has_cap(driver
, sdi
, cg
, key
, SR_CONF_LIST
)) {
393 /* If implemented in config_list(), this denotes the
394 * maximum number of samples a device can send. This
395 * really applies only to logic analyzers, and then
396 * only to those that don't support compression, or
397 * have it turned off by default. The values returned
398 * are the low/high limits. */
399 if (sr_config_list(driver
, sdi
, channel_group
, key
,
401 g_variant_get(gvar
, "(tt)", &low
, &high
);
402 g_variant_unref(gvar
);
403 printf(" Maximum number of samples: %"PRIu64
"\n", high
);
406 } else if (key
== SR_CONF_SAMPLERATE
) {
407 /* Supported samplerates */
408 printf(" %s", srci
->id
);
409 if (maybe_config_list(driver
, sdi
, channel_group
, SR_CONF_SAMPLERATE
,
410 &gvar_dict
) != SR_OK
) {
414 if ((gvar_list
= g_variant_lookup_value(gvar_dict
,
415 "samplerates", G_VARIANT_TYPE("at")))) {
416 uint64
= g_variant_get_fixed_array(gvar_list
,
417 &num_elements
, sizeof(uint64_t));
418 printf(" - supported samplerates:\n");
419 for (i
= 0; i
< num_elements
; i
++) {
420 if (!(s
= sr_samplerate_string(uint64
[i
])))
425 g_variant_unref(gvar_list
);
426 } else if ((gvar_list
= g_variant_lookup_value(gvar_dict
,
427 "samplerate-steps", G_VARIANT_TYPE("at")))) {
428 uint64
= g_variant_get_fixed_array(gvar_list
,
429 &num_elements
, sizeof(uint64_t));
431 if (!(s
= sr_samplerate_string(uint64
[0])))
436 if (!(s
= sr_samplerate_string(uint64
[1])))
441 if (!(s
= sr_samplerate_string(uint64
[2])))
443 printf(" in steps of %s)\n", s
);
445 g_variant_unref(gvar_list
);
447 g_variant_unref(gvar_dict
);
449 } else if (srci
->datatype
== SR_T_UINT64
) {
450 printf(" %s: ", srci
->id
);
452 if (maybe_config_get(driver
, sdi
, channel_group
, key
,
454 tmp_uint64
= g_variant_get_uint64(gvar
);
455 g_variant_unref(gvar
);
458 if (maybe_config_list(driver
, sdi
, channel_group
,
459 key
, &gvar_list
) != SR_OK
) {
461 /* Can't list it, but we have a value to show. */
462 printf("%"PRIu64
" (current)", tmp_uint64
);
467 uint64
= g_variant_get_fixed_array(gvar_list
,
468 &num_elements
, sizeof(uint64_t));
469 printf(" - supported values:\n");
470 for (i
= 0; i
< num_elements
; i
++) {
471 printf(" %"PRIu64
, uint64
[i
]);
472 if (gvar
&& tmp_uint64
== uint64
[i
])
473 printf(" (current)");
476 g_variant_unref(gvar_list
);
478 } else if (srci
->datatype
== SR_T_STRING
) {
479 printf(" %s: ", srci
->id
);
480 if (maybe_config_get(driver
, sdi
, channel_group
, key
,
482 tmp_str
= g_strdup(g_variant_get_string(gvar
, NULL
));
483 g_variant_unref(gvar
);
487 if (maybe_config_list(driver
, sdi
, channel_group
, key
,
490 /* Can't list it, but we have a value to show. */
491 printf("%s (current)", tmp_str
);
498 stropts
= g_variant_get_strv(gvar
, &num_elements
);
499 for (i
= 0; i
< num_elements
; i
++) {
502 printf("%s", stropts
[i
]);
503 if (tmp_str
&& !strcmp(tmp_str
, stropts
[i
]))
504 printf(" (current)");
509 g_variant_unref(gvar
);
511 } else if (srci
->datatype
== SR_T_UINT64_RANGE
) {
512 printf(" %s: ", srci
->id
);
513 if (maybe_config_list(driver
, sdi
, channel_group
, key
,
514 &gvar_list
) != SR_OK
) {
519 if (maybe_config_get(driver
, sdi
, channel_group
, key
, &gvar
) == SR_OK
) {
520 g_variant_get(gvar
, "(tt)", &cur_low
, &cur_high
);
521 g_variant_unref(gvar
);
527 num_elements
= g_variant_n_children(gvar_list
);
528 for (i
= 0; i
< num_elements
; i
++) {
529 gvar
= g_variant_get_child_value(gvar_list
, i
);
530 g_variant_get(gvar
, "(tt)", &low
, &high
);
531 g_variant_unref(gvar
);
534 printf("%"PRIu64
"-%"PRIu64
, low
, high
);
535 if (low
== cur_low
&& high
== cur_high
)
536 printf(" (current)");
539 g_variant_unref(gvar_list
);
541 } else if (srci
->datatype
== SR_T_BOOL
) {
542 printf(" %s: ", srci
->id
);
543 if (maybe_config_get(driver
, sdi
, channel_group
, key
,
545 if (g_variant_get_boolean(gvar
))
546 printf("on (current), off\n");
548 printf("on, off (current)\n");
549 g_variant_unref(gvar
);
553 } else if (srci
->datatype
== SR_T_DOUBLE_RANGE
) {
554 printf(" %s: ", srci
->id
);
555 if (maybe_config_list(driver
, sdi
, channel_group
, key
,
556 &gvar_list
) != SR_OK
) {
561 if (maybe_config_get(driver
, sdi
, channel_group
, key
, &gvar
) == SR_OK
) {
562 g_variant_get(gvar
, "(dd)", &dcur_low
, &dcur_high
);
563 g_variant_unref(gvar
);
569 num_elements
= g_variant_n_children(gvar_list
);
570 for (i
= 0; i
< num_elements
; i
++) {
571 gvar
= g_variant_get_child_value(gvar_list
, i
);
572 g_variant_get(gvar
, "(dd)", &dlow
, &dhigh
);
573 g_variant_unref(gvar
);
576 printf("%.1f-%.1f", dlow
, dhigh
);
577 if (dlow
== dcur_low
&& dhigh
== dcur_high
)
578 printf(" (current)");
581 g_variant_unref(gvar_list
);
583 } else if (srci
->datatype
== SR_T_FLOAT
) {
584 printf(" %s: ", srci
->id
);
585 if (maybe_config_get(driver
, sdi
, channel_group
, key
,
587 printf("%f\n", g_variant_get_double(gvar
));
588 g_variant_unref(gvar
);
592 } else if (srci
->datatype
== SR_T_RATIONAL_PERIOD
593 || srci
->datatype
== SR_T_RATIONAL_VOLT
) {
594 printf(" %s", srci
->id
);
595 if (maybe_config_get(driver
, sdi
, channel_group
, key
,
597 g_variant_get(gvar
, "(tt)", &cur_p
, &cur_q
);
598 g_variant_unref(gvar
);
602 if (maybe_config_list(driver
, sdi
, channel_group
,
603 key
, &gvar_list
) != SR_OK
) {
607 printf(" - supported values:\n");
608 num_elements
= g_variant_n_children(gvar_list
);
609 for (i
= 0; i
< num_elements
; i
++) {
610 gvar
= g_variant_get_child_value(gvar_list
, i
);
611 g_variant_get(gvar
, "(tt)", &p
, &q
);
612 if (srci
->datatype
== SR_T_RATIONAL_PERIOD
)
613 s
= sr_period_string(p
* q
);
615 s
= sr_voltage_string(p
, q
);
618 if (p
== cur_p
&& q
== cur_q
)
619 printf(" (current)");
622 g_variant_unref(gvar_list
);
626 /* Everything else */
627 printf(" %s\n", srci
->id
);
630 g_variant_unref(gvar_opts
);
637 void show_pd_detail(void)
639 struct srd_decoder
*dec
;
640 struct srd_decoder_option
*o
;
641 struct srd_channel
*pdch
;
642 struct srd_decoder_annotation_row
*r
;
645 char **pdtokens
, **pdtok
, *optsep
, **ann
, *val
, *doc
;
647 pdtokens
= g_strsplit(opt_pds
, ",", -1);
648 for (pdtok
= pdtokens
; *pdtok
; pdtok
++) {
650 if ((optsep
= strchr(*pdtok
, ':')))
652 if (!(dec
= srd_decoder_get_by_id(*pdtok
))) {
653 g_critical("Protocol decoder %s not found.", *pdtok
);
656 printf("ID: %s\nName: %s\nLong name: %s\nDescription: %s\n",
657 dec
->id
, dec
->name
, dec
->longname
, dec
->desc
);
658 printf("License: %s\n", dec
->license
);
659 printf("Annotation classes:\n");
660 if (dec
->annotations
) {
661 for (l
= dec
->annotations
; l
; l
= l
->next
) {
663 printf("- %s: %s\n", ann
[0], ann
[1]);
668 printf("Annotation rows:\n");
669 if (dec
->annotation_rows
) {
670 for (l
= dec
->annotation_rows
; l
; l
= l
->next
) {
672 printf("- %s (%s): ", r
->id
, r
->desc
);
673 for (ll
= r
->ann_classes
; ll
; ll
= ll
->next
) {
674 idx
= GPOINTER_TO_INT(ll
->data
);
675 ann
= g_slist_nth_data(dec
->annotations
, idx
);
676 printf("%s", ann
[0]);
685 printf("Required channels:\n");
687 for (l
= dec
->channels
; l
; l
= l
->next
) {
689 printf("- %s (%s): %s\n",
690 pdch
->id
, pdch
->name
, pdch
->desc
);
695 printf("Optional channels:\n");
696 if (dec
->opt_channels
) {
697 for (l
= dec
->opt_channels
; l
; l
= l
->next
) {
699 printf("- %s (%s): %s\n",
700 pdch
->id
, pdch
->name
, pdch
->desc
);
705 printf("Options:\n");
707 for (l
= dec
->options
; l
; l
= l
->next
) {
709 printf("- %s: %s (", o
->id
, o
->desc
);
710 for (ol
= o
->values
; ol
; ol
= ol
->next
) {
711 val
= g_variant_print(ol
->data
, FALSE
);
715 val
= g_variant_print(o
->def
, FALSE
);
716 printf("default %s)\n", val
);
722 if ((doc
= srd_decoder_doc_get(dec
))) {
723 printf("Documentation:\n%s\n",
724 doc
[0] == '\n' ? doc
+ 1 : doc
);
729 g_strfreev(pdtokens
);
733 void show_input(void)
735 const struct sr_input_module
*imod
;
736 const struct sr_option
**opts
;
741 tok
= g_strsplit(opt_input_format
, ":", 0);
742 if (!tok
[0] || !(imod
= sr_input_find(tok
[0])))
743 g_critical("Input module '%s' not found.", opt_input_format
);
745 printf("ID: %s\nName: %s\n", sr_input_id_get(imod
),
746 sr_input_name_get(imod
));
747 printf("Description: %s\n", sr_input_description_get(imod
));
748 if ((opts
= sr_input_options_get(imod
))) {
749 printf("Options:\n");
750 for (i
= 0; opts
[i
]; i
++) {
751 printf(" %s: %s", opts
[i
]->id
, opts
[i
]->desc
);
753 s
= g_variant_print(opts
[i
]->def
, FALSE
);
754 printf(" (default %s", s
);
756 if (opts
[i
]->values
) {
757 printf(", possible values ");
758 for (l
= opts
[i
]->values
; l
; l
= l
->next
) {
759 s
= g_variant_print((GVariant
*)l
->data
, FALSE
);
760 printf("%s%s", s
, l
->next
? ", " : "");
768 sr_input_options_free(opts
);
773 void show_output(void)
775 const struct sr_output_module
*omod
;
776 const struct sr_option
**opts
;
781 tok
= g_strsplit(opt_output_format
, ":", 0);
782 if (!tok
[0] || !(omod
= sr_output_find(tok
[0])))
783 g_critical("Output module '%s' not found.", opt_output_format
);
785 printf("ID: %s\nName: %s\n", sr_output_id_get(omod
),
786 sr_output_name_get(omod
));
787 printf("Description: %s\n", sr_output_description_get(omod
));
788 if ((opts
= sr_output_options_get(omod
))) {
789 printf("Options:\n");
790 for (i
= 0; opts
[i
]; i
++) {
791 printf(" %s: %s", opts
[i
]->id
, opts
[i
]->desc
);
793 s
= g_variant_print(opts
[i
]->def
, FALSE
);
794 printf(" (default %s", s
);
796 if (opts
[i
]->values
) {
797 printf(", possible values ");
798 for (l
= opts
[i
]->values
; l
; l
= l
->next
) {
799 s
= g_variant_print((GVariant
*)l
->data
, FALSE
);
800 printf("%s%s", s
, l
->next
? ", " : "");
808 sr_output_options_free(opts
);
813 void show_transform(void)
815 const struct sr_transform_module
*tmod
;
816 const struct sr_option
**opts
;
821 tok
= g_strsplit(opt_transform_module
, ":", 0);
822 if (!tok
[0] || !(tmod
= sr_transform_find(tok
[0])))
823 g_critical("Transform module '%s' not found.", opt_transform_module
);
825 printf("ID: %s\nName: %s\n", sr_transform_id_get(tmod
),
826 sr_transform_name_get(tmod
));
827 printf("Description: %s\n", sr_transform_description_get(tmod
));
828 if ((opts
= sr_transform_options_get(tmod
))) {
829 printf("Options:\n");
830 for (i
= 0; opts
[i
]; i
++) {
831 printf(" %s: %s", opts
[i
]->id
, opts
[i
]->desc
);
833 s
= g_variant_print(opts
[i
]->def
, FALSE
);
834 printf(" (default %s", s
);
836 if (opts
[i
]->values
) {
837 printf(", possible values ");
838 for (l
= opts
[i
]->values
; l
; l
= l
->next
) {
839 s
= g_variant_print((GVariant
*)l
->data
, FALSE
);
840 printf("%s%s", s
, l
->next
? ", " : "");
848 sr_transform_options_free(opts
);