diff --git a/include/villas/cfg.h b/include/villas/cfg.h index 9c8581ee2..d8b940ad4 100644 --- a/include/villas/cfg.h +++ b/include/villas/cfg.h @@ -31,6 +31,11 @@ struct cfg { struct log log; struct api api; struct web web; + + struct { + int argc; + char **argv; + } cli; config_t cfg; /**< Pointer to configuration file */ json_t *json; /**< JSON representation of the same config. */ @@ -60,3 +65,5 @@ int cfg_destroy(struct cfg *cfg); * @retval <0 Error. Something went wrong. */ int cfg_parse(struct cfg *cfg, const char *uri); + +int cfg_parse_cli(struct cfg *cfg, int argc, char *argv[]); \ No newline at end of file diff --git a/lib/cfg.c b/lib/cfg.c index 6d4eafae5..e55f2bc1c 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -97,6 +97,16 @@ int cfg_destroy(struct cfg *cfg) return 0; } +int cfg_parse_cli(struct cfg *cfg, int argc, char *argv[]) +{ + cfg->cli.argc = argc; + cfg->cli.argv = argv; + + char *uri = (argc == 2) ? argv[1] : NULL; + + return cfg_parse(cfg, uri); +} + int cfg_parse(struct cfg *cfg, const char *uri) { config_setting_t *cfg_root, *cfg_nodes, *cfg_paths, *cfg_plugins, *cfg_logging, *cfg_web;