]> sigrok.org Git - libsigrok.git/blobdiff - src/input/csv.c
input: Added preferred file extension field
[libsigrok.git] / src / input / csv.c
index 180ff3df264c6aaac50f43c69d1f710748e78115..e89f99aa6852ed02be46c3bbea4f835292375ebc 100644 (file)
@@ -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(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
        in->priv = inc = g_malloc0(sizeof(struct context));
 
        inc->single_column = g_variant_get_int32(g_hash_table_lookup(options, "single-column"));
@@ -667,6 +667,13 @@ static int process_buffer(struct sr_input *in)
                        continue;
                }
 
+               /* Skip the header line, its content was used as the channel names. */
+               if (inc->header) {
+                       sr_spew("Header line %zu skipped.", inc->line_number);
+                       inc->header = FALSE;
+                       continue;
+               }
+
                if (!(columns = parse_line(lines[l], inc, max_columns))) {
                        sr_err("Error while parsing line %zu.", inc->line_number);
                        return SR_ERR;
@@ -812,6 +819,7 @@ SR_PRIV struct sr_input_module input_csv = {
        .id = "csv",
        .name = "CSV",
        .desc = "Comma-separated values",
+       .exts = (const char*[]){"csv", NULL},
        .metadata = { SR_INPUT_META_MIMETYPE },
        .options = get_options,
        .format_match = format_match,