X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fcsv.c;h=c2625aa2febb2c48284fc9de1d253eb2205ba3b7;hb=f2209364737835ba78126cf7f2a707f63182f0e6;hp=ece68a98102ccfe670d14660f84a5b72711bc218;hpb=41d214f61a1683fca49b9dc687045afc2ce42007;p=libsigrok.git diff --git a/src/input/csv.c b/src/input/csv.c index ece68a98..c2625aa2 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -138,9 +138,9 @@ static int format_match(GHashTable *metadata) buf = g_hash_table_lookup(metadata, GINT_TO_POINTER(SR_INPUT_META_MIMETYPE)); if (!strcmp(buf, "text/csv")) - return TRUE; + return SR_OK; - return FALSE; + return SR_ERR; } static void strip_comment(char *buf, const GString *prefix) @@ -393,7 +393,7 @@ static int init(struct sr_input *in, GHashTable *options) struct context *inc; const char *s; - in->sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, NULL, NULL, NULL); + in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL); in->priv = inc = g_malloc0(sizeof(struct context)); inc->single_column = g_variant_get_int32(g_hash_table_lookup(options, "single-column")); @@ -429,11 +429,7 @@ static int init(struct sr_input *in, GHashTable *options) g_string_truncate(inc->comment, 0); } - s = g_variant_get_string(g_hash_table_lookup(options, "samplerate"), NULL); - if (sr_parse_sizestring(s, &inc->samplerate) != SR_OK) { - sr_err("Invalid samplerate '%s'.", s); - return SR_ERR_ARG; - } + inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate")); inc->first_channel = g_variant_get_int32(g_hash_table_lookup(options, "first-channel")); @@ -767,7 +763,7 @@ static struct sr_option options[] = { { "first-channel", "First channel", "Column number of first channel", NULL, NULL }, { "header", "Header", "Treat first line as header with channel names", NULL, NULL }, { "startline", "Start line", "Line number at which to start processing samples", NULL, NULL }, - { 0 } + ALL_ZERO }; static struct sr_option *get_options(void) @@ -778,7 +774,7 @@ static struct sr_option *get_options(void) options[2].def = g_variant_ref_sink(g_variant_new_string(",")); options[3].def = g_variant_ref_sink(g_variant_new_string("bin")); options[4].def = g_variant_ref_sink(g_variant_new_string(";")); - options[5].def = g_variant_ref_sink(g_variant_new_string("0")); + options[5].def = g_variant_ref_sink(g_variant_new_uint64(0)); options[6].def = g_variant_ref_sink(g_variant_new_int32(0)); options[7].def = g_variant_ref_sink(g_variant_new_boolean(FALSE)); options[8].def = g_variant_ref_sink(g_variant_new_int32(1));