README: Drop trailing whitespace.
[sigrok-cli.git] / show.c
diff --git a/show.c b/show.c
index 7d02326e86bad5860b698c38a9d4106fcd88d61f..9491110bdcfdbb82d1c0f469a02e47d043fb0875 100644 (file)
--- a/show.c
+++ b/show.c
@@ -57,6 +57,70 @@ static gint sort_pds(gconstpointer a, gconstpointer b)
 #endif
 
 void show_version(void)
 #endif
 
 void show_version(void)
+{
+       GString *s;
+       GSList *l, *l_orig, *m;
+       char *str;
+       const char *lib, *version;
+
+       printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING);
+
+       printf("Libraries and features:\n");
+
+       printf("- libsigrok %s/%s (rt: %s/%s).\n",
+               SR_PACKAGE_VERSION_STRING, SR_LIB_VERSION_STRING,
+               sr_package_version_string_get(), sr_lib_version_string_get());
+
+       s = g_string_sized_new(200);
+       g_string_append(s, " - Libs:\n");
+       l_orig = sr_buildinfo_libs_get();
+       for (l = l_orig; l; l = l->next) {
+               m = l->data;
+               lib = m->data;
+               version = m->next->data;
+               g_string_append_printf(s, "  - %s %s\n", lib, version);
+               g_slist_free_full(m, g_free);
+       }
+       g_slist_free(l_orig);
+       s->str[s->len - 1] = '\0';
+       printf("%s\n", s->str);
+       g_string_free(s, TRUE);
+
+       str = sr_buildinfo_host_get();
+       printf("  - Host: %s.\n", str);
+       g_free(str);
+
+       str = sr_buildinfo_scpi_backends_get();
+       printf("  - SCPI backends: %s.\n", str);
+       g_free(str);
+
+#ifdef HAVE_SRD
+       printf("- libsigrokdecode %s/%s (rt: %s/%s).\n",
+               SRD_PACKAGE_VERSION_STRING, SRD_LIB_VERSION_STRING,
+               srd_package_version_string_get(), srd_lib_version_string_get());
+
+       s = g_string_sized_new(200);
+       g_string_append(s, " - Libs:\n");
+       l_orig = srd_buildinfo_libs_get();
+       for (l = l_orig; l; l = l->next) {
+               m = l->data;
+               lib = m->data;
+               version = m->next->data;
+               g_string_append_printf(s, "  - %s %s\n", lib, version);
+               g_slist_free_full(m, g_free);
+       }
+       g_slist_free(l_orig);
+       s->str[s->len - 1] = '\0';
+       printf("%s\n", s->str);
+       g_string_free(s, TRUE);
+
+       str = srd_buildinfo_host_get();
+       printf("  - Host: %s.\n", str);
+       g_free(str);
+#endif
+}
+
+void show_supported(void)
 {
        struct sr_dev_driver **drivers, *driver;
        const struct sr_input_module **inputs, *input;
 {
        struct sr_dev_driver **drivers, *driver;
        const struct sr_input_module **inputs, *input;
@@ -69,15 +133,6 @@ void show_version(void)
        struct srd_decoder *dec;
 #endif
 
        struct srd_decoder *dec;
 #endif
 
-       printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING);
-
-       printf("Using libsigrok %s (lib version %s).\n",
-              sr_package_version_string_get(), sr_lib_version_string_get());
-#ifdef HAVE_SRD
-       printf("Using libsigrokdecode %s (lib version %s).\n\n",
-              srd_package_version_string_get(), srd_lib_version_string_get());
-#endif
-
        printf("Supported hardware drivers:\n");
        drivers = sr_driver_list(sr_ctx);
        for (sl = NULL, i = 0; drivers[i]; i++)
        printf("Supported hardware drivers:\n");
        drivers = sr_driver_list(sr_ctx);
        for (sl = NULL, i = 0; drivers[i]; i++)
@@ -610,7 +665,7 @@ void show_dev_detail(void)
                                gvar = g_variant_get_child_value(gvar_list, i);
                                g_variant_get(gvar, "(tt)", &p, &q);
                                if (srci->datatype == SR_T_RATIONAL_PERIOD)
                                gvar = g_variant_get_child_value(gvar_list, i);
                                g_variant_get(gvar, "(tt)", &p, &q);
                                if (srci->datatype == SR_T_RATIONAL_PERIOD)
-                                       s = sr_period_string(p * q);
+                                       s = sr_period_string(p, q);
                                else
                                        s = sr_voltage_string(p, q);
                                printf("      %s", s);
                                else
                                        s = sr_voltage_string(p, q);
                                printf("      %s", s);
@@ -674,7 +729,7 @@ void show_dev_detail(void)
 }
 
 #ifdef HAVE_SRD
 }
 
 #ifdef HAVE_SRD
-void show_pd_detail(void)
+static void show_pd_detail_single(const char *pd)
 {
        struct srd_decoder *dec;
        struct srd_decoder_option *o;
 {
        struct srd_decoder *dec;
        struct srd_decoder_option *o;
@@ -682,9 +737,9 @@ void show_pd_detail(void)
        struct srd_decoder_annotation_row *r;
        GSList *l, *ll, *ol;
        int idx;
        struct srd_decoder_annotation_row *r;
        GSList *l, *ll, *ol;
        int idx;
-       char **pdtokens, **pdtok, *optsep, **ann, **bin, *val, *doc;
+       char **pdtokens, **pdtok, *optsep, **ann, **bin, *val, *doc, *str;
 
 
-       pdtokens = g_strsplit(opt_pds, ",", -1);
+       pdtokens = g_strsplit(pd, ",", -1);
        for (pdtok = pdtokens; *pdtok; pdtok++) {
                /* Strip options. */
                if ((optsep = strchr(*pdtok, ':')))
        for (pdtok = pdtokens; *pdtok; pdtok++) {
                /* Strip options. */
                if ((optsep = strchr(*pdtok, ':')))
@@ -696,6 +751,24 @@ void show_pd_detail(void)
                printf("ID: %s\nName: %s\nLong name: %s\nDescription: %s\n",
                                dec->id, dec->name, dec->longname, dec->desc);
                printf("License: %s\n", dec->license);
                printf("ID: %s\nName: %s\nLong name: %s\nDescription: %s\n",
                                dec->id, dec->name, dec->longname, dec->desc);
                printf("License: %s\n", dec->license);
+               printf("Possible decoder input IDs:\n");
+               if (dec->inputs) {
+                       for (l = dec->inputs; l; l = l->next) {
+                               str = l->data;
+                               printf("- %s\n", str);
+                       }
+               } else {
+                       printf("None.\n");
+               }
+               printf("Possible decoder output IDs:\n");
+               if (dec->outputs) {
+                       for (l = dec->outputs; l; l = l->next) {
+                               str = l->data;
+                               printf("- %s\n", str);
+                       }
+               } else {
+                       printf("None.\n");
+               }
                printf("Annotation classes:\n");
                if (dec->annotations) {
                        for (l = dec->annotations; l; l = l->next) {
                printf("Annotation classes:\n");
                if (dec->annotations) {
                        for (l = dec->annotations; l; l = l->next) {
@@ -777,6 +850,12 @@ void show_pd_detail(void)
 
        g_strfreev(pdtokens);
 }
 
        g_strfreev(pdtokens);
 }
+
+void show_pd_detail(void)
+{
+       for (int i = 0; opt_pds[i]; i++)
+               show_pd_detail_single(opt_pds[i]);
+}
 #endif
 
 void show_input(void)
 #endif
 
 void show_input(void)