diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2014-10-14 19:05:06 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2014-10-14 19:05:06 +0200 |
commit | 9cb2e89a3c1d8224bb4a7da02e9874bc2d92fde5 (patch) | |
tree | ed6042fcc53b3dd89cde9d5e47c4e361ba364585 | |
parent | 7b5df639850f248da957c3bd371da3604bf8de05 (diff) | |
download | sigrok-test-9cb2e89a3c1d8224bb4a7da02e9874bc2d92fde5.tar.gz sigrok-test-9cb2e89a3c1d8224bb4a7da02e9874bc2d92fde5.zip |
runtc: Add support for integer PD options.
So far only string options were supported.
-rw-r--r-- | decoder/runtc.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/decoder/runtc.c b/decoder/runtc.c index f58e004..9dcb66d 100644 --- a/decoder/runtc.c +++ b/decoder/runtc.c @@ -332,10 +332,12 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) GVariant *gvar; GHashTable *channels, *opts; GSList *pdl, *l; - int idx; + int idx, i; int max_channel; char **decoder_class; struct sr_session *sr_sess; + gboolean is_number; + const char *s; if (op->outfile) { if ((op->outfd = open(op->outfile, O_CREAT|O_WRONLY, 0600)) == -1) { @@ -378,7 +380,22 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) (GDestroyNotify)g_variant_unref); for (l = pd->options; l; l = l->next) { option = l->data; - g_hash_table_insert(opts, option->key, option->value); + + is_number = TRUE; + s = g_variant_get_string(option->value, NULL); + for (i = 0; i < (int)strlen(s); i++) { + if (!isdigit(s[i])) + is_number = FALSE; + } + + if (is_number) { + /* Integer option value */ + g_hash_table_insert(opts, option->key, + g_variant_new_int64(strtoull(s, NULL, 10))); + } else { + /* String option value */ + g_hash_table_insert(opts, option->key, option->value); + } } if (!(di = srd_inst_new(sess, pd->name, opts))) return FALSE; |