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.
This commit is contained in:
parent
ff17e6ba50
commit
543d45c581
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue