summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--minecctl/minecctl-rcon.c27
-rw-r--r--minecctl/minecctl.c16
-rw-r--r--minecctl/minecctl.h2
3 files changed, 22 insertions, 23 deletions
diff --git a/minecctl/minecctl-rcon.c b/minecctl/minecctl-rcon.c
index f074f3c..27c586c 100644
--- a/minecctl/minecctl-rcon.c
+++ b/minecctl/minecctl-rcon.c
@@ -112,13 +112,13 @@ rcon_login(struct cfg *cfg, struct server *server)
assert_die(cfg && server, "invalid arguments");
if (list_empty(&server->rcon_addrs)) {
- error("%s: rcon address unknown", server->shortname);
+ error("%s: rcon address unknown", server->name);
goto error;
}
fd = connect_any(&server->rcon_addrs, true);
if (fd < 0) {
- error("%s: unable to connect", server->shortname);
+ error("%s: unable to connect", server->name);
goto error;
}
@@ -126,7 +126,7 @@ rcon_login(struct cfg *cfg, struct server *server)
server->rcon_password = ask_password();
if (!server->rcon_password) {
- error("%s: can't login - password missing", server->shortname);
+ error("%s: can't login - password missing", server->name);
goto error;
}
@@ -140,14 +140,12 @@ rcon_login(struct cfg *cfg, struct server *server)
server->rcon_password = NULL;
if (rtype == RCON_PACKET_LOGIN_OK)
- verbose("%s: login ok", server->shortname);
+ verbose("%s: login ok", server->name);
else if (rtype == RCON_PACKET_LOGIN_FAIL) {
- info("%s: login failure, invalid password?",
- server->shortname);
+ info("%s: login failure, invalid password?", server->name);
goto error;
} else {
- error("%s: invalid return code: %" PRIi32,
- server->shortname, rtype);
+ error("%s: invalid return code: %" PRIi32, server->name, rtype);
goto error;
}
@@ -224,7 +222,7 @@ get_one_status(int fd, char *buf, size_t len, const char *cmd,
va_list ap;
int r;
- send_msg(fd, buf, buflen, RCON_PACKET_COMMAND, cmd, &rtype, reply);
+ send_msg(fd, buf, len, RCON_PACKET_COMMAND, cmd, &rtype, reply);
if (rtype != RCON_PACKET_RESPONSE)
die("Invalid return code: %" PRIi32, rtype);
@@ -358,16 +356,16 @@ stop_one_server(struct cfg *cfg, struct server *server)
if (!get_player_count(fd, &current, NULL)) {
error("%s: unable to get player count, not stopping",
- server->shortname);
+ server->name);
return;
} else if (current > 0) {
error("%s: has active players (use -f to force)",
- server->shortname);
+ server->name);
return;
}
}
- info("%s: sending stop command", server->shortname);
+ info("%s: sending stop command", server->name);
send_cmd(fd, "stop");
close(fd);
}
@@ -421,8 +419,9 @@ do_console(struct cfg *cfg)
return;
prompt = alloca(strlen(program_invocation_short_name) +
- STRLEN(" (") + strlen(server->shortname) + STRLEN("): ") + 1);
- sprintf(prompt, "%s (%s): ", program_invocation_short_name, server->shortname);
+ STRLEN(" (") + strlen(server->name) + STRLEN("): ") + 1);
+ sprintf(prompt, "%s (%s): ", program_invocation_short_name,
+ server->name);
while (true) {
char *tmp;
diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c
index 01f8163..19bcc1e 100644
--- a/minecctl/minecctl.c
+++ b/minecctl/minecctl.c
@@ -41,7 +41,7 @@ dump_config()
list_for_each_entry(server, &cfg->servers, list) {
info(" * server");
- info(" shortname : %s", server->shortname);
+ info(" name : %s", server->name);
info(" filename : %s", server->filename);
info(" rcon_password : %s", server->rcon_password);
info(" file_read : %s", server->file_read ? "yes" : "no");
@@ -217,7 +217,7 @@ get_servers()
suffix = strrchr(dent->d_name, '.');
assert_die(suffix, "Error parsing filename");
*suffix = '\0';
- server->shortname = xstrdup(dent->d_name);
+ server->name = xstrdup(dent->d_name);
list_add(&server->list, &cfg->servers);
}
@@ -271,7 +271,7 @@ create_server_from_cmdline_args()
if (!str_to_addrs(cfg->addrstr, &server->rcon_addrs))
goto error;
- server->shortname = cfg->addrstr;
+ server->name = cfg->addrstr;
cfg->addrstr = NULL;
}
@@ -279,8 +279,8 @@ create_server_from_cmdline_args()
if (!str_to_addrs(cfg->mcaddrstr, &server->mc_addrs))
goto error;
- if (!server->shortname)
- server->shortname = cfg->mcaddrstr;
+ if (!server->name)
+ server->name = cfg->mcaddrstr;
else
xfree(cfg->mcaddrstr);
@@ -297,7 +297,7 @@ create_server_from_cmdline_args()
error:
/* FIXME: free addrs */
- xfree(server->shortname);
+ xfree(server->name);
xfree(server);
return false;
}
@@ -308,7 +308,7 @@ do_list(struct cfg *cfg)
struct server *server;
list_for_each_entry(server, &cfg->servers, list)
- info("%s", server->shortname);
+ info("%s", server->name);
}
static void
@@ -319,7 +319,7 @@ set_server(const char *name)
assert_die(cfg, "invalid arguments");
list_for_each_entry(server, &cfg->servers, list) {
- if (streq(name, server->shortname)) {
+ if (streq(name, server->name)) {
list_rotate_to_front(&server->list, &cfg->servers);
return;
}
diff --git a/minecctl/minecctl.h b/minecctl/minecctl.h
index 7146a08..604225d 100644
--- a/minecctl/minecctl.h
+++ b/minecctl/minecctl.h
@@ -3,8 +3,8 @@
struct server {
bool file_read;
+ char *name;
char *filename;
- char *shortname;
char *rcon_password;
struct list_head rcon_addrs;
struct list_head mc_addrs;