Commit c9ef451e authored by Adam Wujek's avatar Adam Wujek 💬

userspace/wrsw_hal: add -f parameter to pass dot-config location

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 97b47560
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
static int daemon_mode = 0; static int daemon_mode = 0;
static hal_cleanup_callback_t cleanup_cb[MAX_CLEANUP_CALLBACKS]; static hal_cleanup_callback_t cleanup_cb[MAX_CLEANUP_CALLBACKS];
static char *logfilename; static char *logfilename;
static char *dotconfigname = "/wr/etc/dot-config";
struct hal_shmem_header *hal_shmem; struct hal_shmem_header *hal_shmem;
...@@ -84,11 +85,15 @@ static int hal_init(void) ...@@ -84,11 +85,15 @@ static int hal_init(void)
memset(cleanup_cb, 0, sizeof(cleanup_cb)); memset(cleanup_cb, 0, sizeof(cleanup_cb));
line = libwr_cfg_read_file("/wr/etc/dot-config"); /* FIXME: accept -f */ pr_info("Using file %s as dot-config\n", dotconfigname);
line = libwr_cfg_read_file(dotconfigname);
if (line == -1) if (line == -1)
pr_error("Unable to read dot-config or error in line 1\n"); pr_error("Unable to read dot-config file %s or error in line"
"1\n", dotconfigname);
else if (line) else if (line)
pr_error("Error in dot-config, error in line %d\n", -line); pr_error("Error in dot-config file %s, error in line %d\n",
dotconfigname, -line);
shw_sfp_read_db(); shw_sfp_read_db();
...@@ -170,7 +175,7 @@ static void hal_parse_cmdline(int argc, char *argv[]) ...@@ -170,7 +175,7 @@ static void hal_parse_cmdline(int argc, char *argv[])
{ {
int opt; int opt;
while ((opt = getopt(argc, argv, "dhqvl:")) != -1) { while ((opt = getopt(argc, argv, "dhqvl:f:")) != -1) {
switch (opt) { switch (opt) {
case 'd': case 'd':
daemon_mode = 1; daemon_mode = 1;
...@@ -188,6 +193,11 @@ static void hal_parse_cmdline(int argc, char *argv[]) ...@@ -188,6 +193,11 @@ static void hal_parse_cmdline(int argc, char *argv[])
case 'q': break; /* done in wrs_msg_init() */ case 'q': break; /* done in wrs_msg_init() */
case 'v': break; /* done in wrs_msg_init() */ case 'v': break; /* done in wrs_msg_init() */
case 'f':
/* custom dot-config file */
dotconfigname = optarg;
break;
default: default:
fprintf(stderr, fprintf(stderr,
"Unrecognized option. Call %s -h for help.\n", "Unrecognized option. Call %s -h for help.\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment