From: Bert Vermeulen Date: Thu, 21 Feb 2013 13:48:43 +0000 (+0100) Subject: input: feed the filename to the module's init() function X-Git-Tag: dsupstream~264 X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=543d45c581658851b41af42ebdbc476ccf3d88d3 input: feed the filename to the module's init() function This is essential if a format contains e.g. the number of probes; the init() function needs to initialize the sr_dev_inst struct, but needs access to the file to properly add the probes to it. --- diff --git a/input/binary.c b/input/binary.c index 1c786bae..148c41e7 100644 --- a/input/binary.c +++ b/input/binary.c @@ -50,7 +50,7 @@ static int format_match(const char *filename) return TRUE; } -static int init(struct sr_input *in) +static int init(struct sr_input *in, const char *filename) { struct sr_probe *probe; int num_probes, i; @@ -58,6 +58,8 @@ static int init(struct sr_input *in) char *param; struct context *ctx; + (void)filename; + if (!(ctx = g_try_malloc0(sizeof(*ctx)))) { sr_err("Input format context malloc failed."); return SR_ERR_MALLOC; diff --git a/input/chronovu_la8.c b/input/chronovu_la8.c index d83b547f..991bfeec 100644 --- a/input/chronovu_la8.c +++ b/input/chronovu_la8.c @@ -101,13 +101,15 @@ static int format_match(const char *filename) return TRUE; } -static int init(struct sr_input *in) +static int init(struct sr_input *in, const char *filename) { struct sr_probe *probe; int num_probes, i; char name[SR_MAX_PROBENAME_LEN + 1]; char *param; + (void)filename; + num_probes = DEFAULT_NUM_PROBES; if (in->param) { diff --git a/input/vcd.c b/input/vcd.c index a9963f7e..01dcdb10 100644 --- a/input/vcd.c +++ b/input/vcd.c @@ -311,7 +311,7 @@ static int format_match(const char *filename) return status; } -static int init(struct sr_input *in) +static int init(struct sr_input *in, const char *filename) { struct sr_probe *probe; int num_probes, i; @@ -319,6 +319,8 @@ static int init(struct sr_input *in) char *param; struct context *ctx; + (void)filename; + if (!(ctx = g_try_malloc0(sizeof(*ctx)))) { sr_err("Input format context malloc failed."); return SR_ERR_MALLOC; diff --git a/libsigrok.h b/libsigrok.h index 2c117be1..b6d2b640 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -311,7 +311,7 @@ struct sr_input_format { char *id; char *description; int (*format_match) (const char *filename); - int (*init) (struct sr_input *in); + int (*init) (struct sr_input *in, const char *filename); int (*loadfile) (struct sr_input *in, const char *filename); };