diff --git a/src/common/options.c b/src/common/options.c --- a/src/common/options.c +++ b/src/common/options.c @@ -23,7 +23,7 @@ #include #include -int options_init(int argc, char *argv[], cfg_t **mycfg, cfg_opt_t *myopts, const char *myname, struct options_common **allopts) +int options_init(int argc, char *argv[], cfg_t **mycfg, cfg_opt_t *myopts, char *myname, struct options_common **allopts) { char *configfile; @@ -35,13 +35,36 @@ int options_init(int argc, char *argv[], } /* Conf File Parser */ + cfg_opt_t common_opts[] = + { + CFG_END() + }; + + cfg_opt_t server_opts[] = + { + CFG_STR("username", NULL, CFGF_NONE), + CFG_STR("hostname", NULL, CFGF_NONE), + CFG_STR("method", "ssh", CFGF_NONE), + CFG_END() + }; + cfg_opt_t opts[] = { - CFG_STR("username", "guest", CFGF_NONE), + CFG_SEC("common", + common_opts, + CFGF_NONE), + CFG_SEC("server", + server_opts, + CFGF_MULTI | CFGF_TITLE), + CFG_SEC(myname, + myopts, + 0), CFG_END() }; cfg_t *cfg; - cfg = cfg_init(opts, CFGF_NONE); + + + cfg = cfg_init(opts, 0); switch(cfg_parse(cfg, configfile)) { default: @@ -59,7 +82,7 @@ int options_init(int argc, char *argv[], /* End Conf File Parser */ - printf("Client Username: %s\n", cfg_getstr(cfg, "username")); + printf("Client Username: %s\n", cfg_getstr(cfg_getsec(cfg, "client"), "username")); cfg_free(cfg); return 0; }