From 90e27b4356f2a6ab98e812c4096b0b76f94a8fb3 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 7 Jul 2020 18:41:38 +0200 Subject: Flesh out the ping implementation --- minecctl/rcon-commands.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'minecctl/rcon-commands.c') diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c index f18f082..61a682c 100644 --- a/minecctl/rcon-commands.c +++ b/minecctl/rcon-commands.c @@ -12,8 +12,8 @@ #include "shared/utils.h" #include "shared/rcon-protocol.h" #include "minecctl.h" -#include "rcon-commands.h" #include "server.h" +#include "rcon-commands.h" #include "misc.h" static void send_packet(int sfd, const char *buf, size_t len) @@ -93,6 +93,7 @@ static void send_msg(int sfd, char *buf, size_t len, enum rcon_packet_type type, rcon_packet_id++; } +/* FIXME: return error message */ static int rcon_login(struct cfg *cfg, struct server *server) { const char *error; @@ -296,12 +297,6 @@ bool do_status(struct cfg *cfg) return true; } -bool do_ping(_unused_ struct cfg *cfg) -{ - die("Not implemented"); - return false; -} - static bool get_player_count(int fd, unsigned *current, unsigned *max) { char buf[4096]; @@ -382,18 +377,21 @@ bool do_stop_all(struct cfg *cfg) return rv; } -bool do_rcon_pcount(struct cfg *cfg, unsigned *online, unsigned *max) +bool do_rcon_pcount(struct cfg *cfg, struct server *server, unsigned *online, + unsigned *max, const char **error) { - struct server *server; bool rv; int fd; - server = server_get_default(cfg); fd = rcon_login(cfg, server); - if (fd < 0) + if (fd < 0) { + *error = "failed to login"; return false; + } rv = get_player_count(fd, online, max); + if (!rv) + *error = "failed to get player count"; close(fd); -- cgit v1.2.3