mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
add new cfg_parse_cli function
This commit is contained in:
parent
21d6ff20c4
commit
4ceb3b573d
2 changed files with 17 additions and 0 deletions
|
@ -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[]);
|
10
lib/cfg.c
10
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue