From b72059e22db619adfbd41087ed662c1c79845565 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Fri, 26 Jun 2020 13:02:57 +0200 Subject: Improve config dumping in minecctl --- minecctl/minecctl.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c index bbe605b..bdf51c1 100644 --- a/minecctl/minecctl.c +++ b/minecctl/minecctl.c @@ -26,15 +26,32 @@ static struct cfg *cfg = NULL; static void dump_config() { - info("Configuration:"); + /* FIXME: return unless debugging enabled */ + struct server *server; + struct saddr *saddr; + + info("Configuration"); + info("============="); info("password : %s", cfg->password); info("cfgdir : %s", cfg->cfgdir); info("addrstr : %s", cfg->addrstr); info("cmdstr : %s", cfg->cmdstr); info("cmd : %p", cfg->cmd); info("force stop : %s", cfg->force_stop ? "yes" : "no"); - info("servers : %sempty", list_empty(&cfg->servers) ? "" : "not "); - /* FIXME: dump servers */ + + list_for_each_entry(server, &cfg->servers, list) { + info(" * server"); + info(" shortname : %s", server->shortname); + info(" filename : %s", server->filename); + info(" rcon_password : %s", server->rcon_password); + info(" file_read : %s", server->file_read ? "yes" : "no"); + list_for_each_entry(saddr, &server->rcon_addrs, list) + info(" * rcon addr : %s", saddr->addrstr); + list_for_each_entry(saddr, &server->mc_addrs, list) + info(" * mc addr : %s", saddr->addrstr); + } + + info("============="); } void @@ -418,8 +435,6 @@ parse_command(char * const *argv) default: die("Unreachable"); } - - dump_config(); } static void @@ -437,6 +452,8 @@ parse_cmdline(int argc, char * const *argv) cfg->cfgdir = DEFAULT_CFG_DIR; + /* FIXME: add lint and debug options */ + while (true) { int option_index = 0; static struct option long_options[] = { @@ -528,6 +545,7 @@ main(int argc, char **argv) if (cfg->addrstr || cfg->mcaddrstr) if (!create_server_from_cmdline_args()) goto out; + dump_config(); /* FIXME: Should return bool */ cfg->cmd(cfg); -- cgit v1.2.3