X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fvcd.c;h=75efc0d55efe023c6ae1d1f482c3766a3bcc4ecb;hb=6ec6c43b4738dbc7091f4a49a4ec80ea6102cb52;hp=96bd6335b0b3f67083ee668b0f828031d69fd803;hpb=7066fd466038bb4a8d09751f8a53c2452c5fefc1;p=libsigrok.git diff --git a/src/input/vcd.c b/src/input/vcd.c index 96bd6335..75efc0d5 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -57,11 +57,12 @@ * - more than 64 channels */ +#include #include #include #include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #define LOG_PREFIX "input/vcd" @@ -87,7 +88,6 @@ struct vcd_channel { gchar *identifier; }; - /* * Reads a single VCD section from input file and parses it to name/contents. * e.g. $timescale 1ps $end => "timescale" "1ps" @@ -404,7 +404,6 @@ static void parse_contents(const struct sr_input *in, char *data) static int init(struct sr_input *in, GHashTable *options) { - struct sr_channel *ch; int num_channels, i; char name[16]; struct context *inc; @@ -429,13 +428,12 @@ static int init(struct sr_input *in, GHashTable *options) inc->skip = g_variant_get_int32(g_hash_table_lookup(options, "skip")); inc->skip /= inc->downsample; - in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL); + in->sdi = g_malloc0(sizeof(struct sr_dev_inst)); in->priv = inc; for (i = 0; i < num_channels; i++) { snprintf(name, 16, "%d", i); - ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, name); - in->sdi->channels = g_slist_append(in->sdi->channels, ch); + sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name); } return SR_OK; @@ -503,7 +501,7 @@ static int receive(struct sr_input *in, GString *buf) if (!inc->got_header) { if (!have_header(in->buf)) return SR_OK; - if (!parse_header(in, in->buf) != SR_OK) + if (!parse_header(in, in->buf)) /* There was a header in there, but it was malformed. */ return SR_ERR; @@ -537,14 +535,12 @@ static int end(struct sr_input *in) return ret; } -static int cleanup(struct sr_input *in) +static void cleanup(struct sr_input *in) { struct context *inc; inc = in->priv; g_slist_free_full(inc->channels, free_channel); - - return SR_OK; } static struct sr_option options[] = { @@ -571,6 +567,7 @@ SR_PRIV struct sr_input_module input_vcd = { .id = "vcd", .name = "VCD", .desc = "Value Change Dump", + .exts = (const char*[]){"vcd", NULL}, .metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED }, .options = get_options, .format_match = format_match,