diff --git a/config.c b/config.c index 90e51f4..b75ade3 100644 --- a/config.c +++ b/config.c @@ -20,13 +20,16 @@ #include #include "config.h" -static void scan_line(char *s, struct defaultDS *dds, struct port_defaults *pod) +static void scan_line(char *s, struct config *cfg) { int val; Integer8 i8; UInteger16 u16; UInteger8 u8; + struct defaultDS *dds = cfg->dds; + struct port_defaults *pod = cfg->pod; + if (1 == sscanf(s, " twoStepFlag %d", &val)) { if (val) /* TODO - implement one step */ @@ -79,7 +82,7 @@ static void scan_line(char *s, struct defaultDS *dds, struct port_defaults *pod) } } -int config_read(char *name, struct defaultDS *dds, struct port_defaults *pod) +int config_read(char *name, struct config *cfg) { FILE *fp; char line[1024]; @@ -92,7 +95,7 @@ int config_read(char *name, struct defaultDS *dds, struct port_defaults *pod) } while (fgets(line, sizeof(line), fp)) { - scan_line(line, dds, pod); + scan_line(line, cfg); } fclose(fp); diff --git a/config.h b/config.h index fb33479..dd05d7d 100644 --- a/config.h +++ b/config.h @@ -22,6 +22,11 @@ #include "ds.h" -int config_read(char *name, struct defaultDS *dds, struct port_defaults *pod); +struct config { + struct defaultDS *dds; + struct port_defaults *pod; +}; + +int config_read(char *name, struct config *cfg); #endif diff --git a/ptp4l.c b/ptp4l.c index 845f09a..e461935 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -32,6 +32,7 @@ static int running = 1; static struct defaultDS ds; static struct port_defaults pod; +static struct config cfg_settings; static int generate_clock_identity(struct ClockIdentity *ci, char *name) { @@ -175,7 +176,10 @@ int main(int argc, char *argv[]) return -1; } - if (config && config_read(config, &ds, &pod)) { + cfg_settings.dds = &ds; + cfg_settings.pod = &pod; + + if (config && config_read(config, &cfg_settings)) { fprintf(stderr, "failed to read configuration file\n"); return -1; }