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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init(struct sr_input *in)
|
static int init(struct sr_input *in, const char *filename)
|
||||||
{
|
{
|
||||||
struct sr_probe *probe;
|
struct sr_probe *probe;
|
||||||
int num_probes, i;
|
int num_probes, i;
|
||||||
|
@ -58,6 +58,8 @@ static int init(struct sr_input *in)
|
||||||
char *param;
|
char *param;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
|
||||||
|
(void)filename;
|
||||||
|
|
||||||
if (!(ctx = g_try_malloc0(sizeof(*ctx)))) {
|
if (!(ctx = g_try_malloc0(sizeof(*ctx)))) {
|
||||||
sr_err("Input format context malloc failed.");
|
sr_err("Input format context malloc failed.");
|
||||||
return SR_ERR_MALLOC;
|
return SR_ERR_MALLOC;
|
||||||
|
|
|
@ -101,13 +101,15 @@ static int format_match(const char *filename)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init(struct sr_input *in)
|
static int init(struct sr_input *in, const char *filename)
|
||||||
{
|
{
|
||||||
struct sr_probe *probe;
|
struct sr_probe *probe;
|
||||||
int num_probes, i;
|
int num_probes, i;
|
||||||
char name[SR_MAX_PROBENAME_LEN + 1];
|
char name[SR_MAX_PROBENAME_LEN + 1];
|
||||||
char *param;
|
char *param;
|
||||||
|
|
||||||
|
(void)filename;
|
||||||
|
|
||||||
num_probes = DEFAULT_NUM_PROBES;
|
num_probes = DEFAULT_NUM_PROBES;
|
||||||
|
|
||||||
if (in->param) {
|
if (in->param) {
|
||||||
|
|
|
@ -311,7 +311,7 @@ static int format_match(const char *filename)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init(struct sr_input *in)
|
static int init(struct sr_input *in, const char *filename)
|
||||||
{
|
{
|
||||||
struct sr_probe *probe;
|
struct sr_probe *probe;
|
||||||
int num_probes, i;
|
int num_probes, i;
|
||||||
|
@ -319,6 +319,8 @@ static int init(struct sr_input *in)
|
||||||
char *param;
|
char *param;
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
|
|
||||||
|
(void)filename;
|
||||||
|
|
||||||
if (!(ctx = g_try_malloc0(sizeof(*ctx)))) {
|
if (!(ctx = g_try_malloc0(sizeof(*ctx)))) {
|
||||||
sr_err("Input format context malloc failed.");
|
sr_err("Input format context malloc failed.");
|
||||||
return SR_ERR_MALLOC;
|
return SR_ERR_MALLOC;
|
||||||
|
|
|
@ -311,7 +311,7 @@ struct sr_input_format {
|
||||||
char *id;
|
char *id;
|
||||||
char *description;
|
char *description;
|
||||||
int (*format_match) (const char *filename);
|
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);
|
int (*loadfile) (struct sr_input *in, const char *filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue