]> sigrok.org Git - libsigrok.git/commitdiff
input: feed the filename to the module's init() function
authorBert Vermeulen <redacted>
Thu, 21 Feb 2013 13:48:43 +0000 (14:48 +0100)
committerBert Vermeulen <redacted>
Thu, 21 Feb 2013 14:21:20 +0000 (15:21 +0100)
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.

input/binary.c
input/chronovu_la8.c
input/vcd.c
libsigrok.h

index 1c786baebfc2c71ec6b833fa35ee7f16b476deea..148c41e782433cf4e852dde0b81a393ac110524e 100644 (file)
@@ -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;
index d83b547f280fe218b28dcd644435a8e9c4b69f09..991bfeecc485425fa8ea6f634576d15f58fc12ae 100644 (file)
@@ -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) {
index a9963f7e7682dc136575f785f9471f2e439b7d61..01dcdb10744447ba123bcd7cc0d1d645afd5ef24 100644 (file)
@@ -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;
index 2c117be1af5aef0b7664426e3b813a0289a6e1a1..b6d2b64046ebbda6f2a438a91ea5bf5fea2c1854 100644 (file)
@@ -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);
 };