summaryrefslogtreecommitdiff
path: root/minecctl
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-28 14:58:32 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-28 14:58:32 +0200
commitd3352b997ca59a336a40fe6660c6e5b7079864aa (patch)
treef365d6c0304e512057223e9a3cf37357da44a443 /minecctl
parent99b2c70137fef05a5a18f439b9010ddba455f5cb (diff)
Run clang-format on source tree (excl igmp.c)
Diffstat (limited to 'minecctl')
-rw-r--r--minecctl/mc-commands.c11
-rw-r--r--minecctl/minecctl-commands.h66
-rw-r--r--minecctl/minecctl.c38
-rw-r--r--minecctl/minecctl.h1
-rw-r--r--minecctl/misc-commands.c6
-rw-r--r--minecctl/misc-commands.h1
-rw-r--r--minecctl/misc.c46
-rw-r--r--minecctl/misc.h2
-rw-r--r--minecctl/rcon-commands.c122
-rw-r--r--minecctl/server.c25
10 files changed, 147 insertions, 171 deletions
diff --git a/minecctl/mc-commands.c b/minecctl/mc-commands.c
index 0ac20d0..d4d2846 100644
--- a/minecctl/mc-commands.c
+++ b/minecctl/mc-commands.c
@@ -7,8 +7,7 @@
#include "misc.h"
#include "mc-protocol.h"
-bool
-do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
+bool do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
{
struct server *server;
struct saddr *saddr;
@@ -24,7 +23,7 @@ do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
if (fd < 0) {
error("%s: unable to connect", server->name);
return false;
- }
+ }
/* FIXME: connect_any needs to indicate the address it used */
saddr = list_first_entry(&server->mc_addrs, struct saddr, list);
@@ -33,7 +32,8 @@ do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
goto out;
}
- if (!mc_protocol_create_status_request(buf, sizeof(buf), &plen, saddr)) {
+ if (!mc_protocol_create_status_request(buf, sizeof(buf), &plen,
+ saddr)) {
error("Failed to create req");
goto out;
}
@@ -64,7 +64,7 @@ do_mc_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
break;
}
}
-
+
if (!mc_protocol_parse_status_reply(buf, off, online, max)) {
error("Failed to get player count");
return false;
@@ -74,4 +74,3 @@ out:
close(fd);
return rv;
}
-
diff --git a/minecctl/minecctl-commands.h b/minecctl/minecctl-commands.h
index 444204f..2805a51 100644
--- a/minecctl/minecctl-commands.h
+++ b/minecctl/minecctl-commands.h
@@ -16,35 +16,41 @@ enum commands {
static struct command_list {
const char *name;
enum commands cmd;
-} command_list[] = {
- {
- .name = "list",
- .cmd = CMD_LIST,
- }, {
- .name = "status",
- .cmd = CMD_STATUS,
- }, {
- .name = "ping",
- .cmd = CMD_PING,
- }, {
- .name = "stop",
- .cmd = CMD_STOP,
- }, {
- .name = "stopall",
- .cmd = CMD_STOPALL,
- }, {
- .name = "pcount",
- .cmd = CMD_PCOUNT,
- }, {
- .name = "cmd",
- .cmd = CMD_COMMAND,
- }, {
- .name = "console",
- .cmd = CMD_CONSOLE,
- }, {
- .name = NULL,
- .cmd = CMD_INVALID,
- }
-};
+} command_list[] = { {
+ .name = "list",
+ .cmd = CMD_LIST,
+ },
+ {
+ .name = "status",
+ .cmd = CMD_STATUS,
+ },
+ {
+ .name = "ping",
+ .cmd = CMD_PING,
+ },
+ {
+ .name = "stop",
+ .cmd = CMD_STOP,
+ },
+ {
+ .name = "stopall",
+ .cmd = CMD_STOPALL,
+ },
+ {
+ .name = "pcount",
+ .cmd = CMD_PCOUNT,
+ },
+ {
+ .name = "cmd",
+ .cmd = CMD_COMMAND,
+ },
+ {
+ .name = "console",
+ .cmd = CMD_CONSOLE,
+ },
+ {
+ .name = NULL,
+ .cmd = CMD_INVALID,
+ } };
#endif
diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c
index b93f87b..5ac3942 100644
--- a/minecctl/minecctl.c
+++ b/minecctl/minecctl.c
@@ -22,8 +22,7 @@
#include "config-parser.h"
#include "config.h"
-static void
-dump_config(struct cfg *cfg)
+static void dump_config(struct cfg *cfg)
{
/* FIXME: return unless debugging enabled */
struct server *server;
@@ -44,7 +43,8 @@ dump_config(struct cfg *cfg)
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");
+ 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)
@@ -54,8 +54,7 @@ dump_config(struct cfg *cfg)
info("=============");
}
-_noreturn_ static void
-usage(bool no_error)
+_noreturn_ static void usage(bool no_error)
{
info("Usage: %s [OPTION...] COMMAND\n"
"\n"
@@ -92,8 +91,7 @@ usage(bool no_error)
exit(no_error ? EXIT_FAILURE : EXIT_SUCCESS);
}
-static bool
-str_to_addrs(const char *str, struct list_head *list)
+static bool str_to_addrs(const char *str, struct list_head *list)
{
struct cfg_value value;
char *tmp = NULL;
@@ -124,8 +122,7 @@ out:
return rv;
}
-static bool
-create_server_from_cmdline_args(struct cfg *cfg)
+static bool create_server_from_cmdline_args(struct cfg *cfg)
{
struct server *server;
@@ -167,8 +164,8 @@ error:
return false;
}
-static inline void
-get_optional_server_arg(struct cfg *cfg, char * const **argv, bool more)
+static inline void get_optional_server_arg(struct cfg *cfg, char *const **argv,
+ bool more)
{
if (!cfg->rcon_addrstr) {
if (!**argv) {
@@ -177,7 +174,8 @@ get_optional_server_arg(struct cfg *cfg, char * const **argv, bool more)
}
if (!server_set_default(cfg, **argv)) {
- error("\"%s\" is not a known server or command", **argv);
+ error("\"%s\" is not a known server or command",
+ **argv);
usage(false);
}
@@ -190,8 +188,7 @@ get_optional_server_arg(struct cfg *cfg, char * const **argv, bool more)
}
}
-static void
-parse_command(struct cfg *cfg, char * const *argv)
+static void parse_command(struct cfg *cfg, char *const *argv)
{
enum commands cmd = CMD_INVALID;
@@ -280,8 +277,7 @@ parse_command(struct cfg *cfg, char * const *argv)
}
}
-static void
-parse_cmdline(struct cfg *cfg, int argc, char * const *argv)
+static void parse_cmdline(struct cfg *cfg, int argc, char *const *argv)
{
int c;
char *e;
@@ -299,6 +295,7 @@ parse_cmdline(struct cfg *cfg, int argc, char * const *argv)
while (true) {
int option_index = 0;
+ /* clang-format off */
static struct option long_options[] = {
{ "rcon-password", required_argument, 0, 'p' },
{ "rcon-address", required_argument, 0, 'r' },
@@ -309,9 +306,10 @@ parse_cmdline(struct cfg *cfg, int argc, char * const *argv)
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
};
+ /* clang-format on */
- c = getopt_long(argc, argv, ":p:r:m:c:vfh",
- long_options, &option_index);
+ c = getopt_long(argc, argv, ":p:r:m:c:vfh", long_options,
+ &option_index);
if (c == -1)
break;
@@ -362,8 +360,7 @@ parse_cmdline(struct cfg *cfg, int argc, char * const *argv)
}
}
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
struct cfg cfg = {
.servers = LIST_HEAD_INIT(cfg.servers),
@@ -401,4 +398,3 @@ out:
xfree(cfg.cmdstr);
exit(success ? EXIT_SUCCESS : EXIT_FAILURE);
}
-
diff --git a/minecctl/minecctl.h b/minecctl/minecctl.h
index 60b71b4..259ac52 100644
--- a/minecctl/minecctl.h
+++ b/minecctl/minecctl.h
@@ -16,4 +16,3 @@ struct cfg {
};
#endif
-
diff --git a/minecctl/misc-commands.c b/minecctl/misc-commands.c
index c64a005..52797da 100644
--- a/minecctl/misc-commands.c
+++ b/minecctl/misc-commands.c
@@ -5,8 +5,7 @@
#include "rcon-commands.h"
#include "mc-commands.h"
-bool
-do_list(struct cfg *cfg)
+bool do_list(struct cfg *cfg)
{
struct server *server;
@@ -18,8 +17,7 @@ do_list(struct cfg *cfg)
return true;
}
-bool
-do_pcount(struct cfg *cfg)
+bool do_pcount(struct cfg *cfg)
{
unsigned x, y;
diff --git a/minecctl/misc-commands.h b/minecctl/misc-commands.h
index 8270601..1a4363f 100644
--- a/minecctl/misc-commands.h
+++ b/minecctl/misc-commands.h
@@ -6,4 +6,3 @@ bool do_list(struct cfg *cfg);
bool do_pcount(struct cfg *cfg);
#endif
-
diff --git a/minecctl/misc.c b/minecctl/misc.c
index 72eb03c..8f0761f 100644
--- a/minecctl/misc.c
+++ b/minecctl/misc.c
@@ -11,8 +11,7 @@
bool use_colors = false;
/* FIXME: Can be shared */
-void
-set_use_colors()
+void set_use_colors()
{
int fd;
const char *e;
@@ -37,8 +36,7 @@ set_use_colors()
use_colors = true;
}
-char *
-strv_join(char * const *strv)
+char *strv_join(char *const *strv)
{
size_t len = 0;
char *r, *to;
@@ -61,8 +59,7 @@ strv_join(char * const *strv)
return r;
}
-int
-connect_any(struct list_head *addrs, bool may_fail)
+int connect_any(struct list_head *addrs, bool may_fail)
{
struct saddr *saddr;
bool connected = false;
@@ -78,13 +75,15 @@ connect_any(struct list_head *addrs, bool may_fail)
list_for_each_entry(saddr, addrs, list) {
verbose("Attempting connection to %s", saddr->addrstr);
- sfd = socket(saddr->storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ sfd = socket(saddr->st.ss_family, SOCK_STREAM | SOCK_CLOEXEC,
+ 0);
if (sfd < 0)
die("socket: %m");
socket_set_low_latency(sfd, true, true, true);
- if (connect(sfd, (struct sockaddr *)&saddr->storage, saddr->addrlen) < 0) {
+ if (connect(sfd, (struct sockaddr *)&saddr->st,
+ saddr->addrlen) < 0) {
close(sfd);
continue;
}
@@ -101,8 +100,7 @@ connect_any(struct list_head *addrs, bool may_fail)
return sfd;
}
-char *
-ask_password()
+char *ask_password()
{
struct termios old, new;
char *password = NULL;
@@ -139,8 +137,7 @@ ask_password()
return password;
}
-void
-free_password(char **password)
+void free_password(char **password)
{
if (!password || !*password)
return;
@@ -150,8 +147,7 @@ free_password(char **password)
*password = NULL;
}
-void
-__debug(_unused_ enum debug_lvl lvl, const char *fmt, ...)
+void __debug(_unused_ enum debug_lvl lvl, const char *fmt, ...)
{
va_list ap;
@@ -170,8 +166,7 @@ __debug(_unused_ enum debug_lvl lvl, const char *fmt, ...)
fprintf(stderr, ANSI_NORMAL);
}
-_noreturn_ void
-__die(const char *fmt, ...)
+_noreturn_ void __die(const char *fmt, ...)
{
va_list ap;
@@ -182,8 +177,7 @@ __die(const char *fmt, ...)
exit(EXIT_FAILURE);
}
-void *
-__zmalloc(const char *fn, int line, size_t size)
+void *__zmalloc(const char *fn, int line, size_t size)
{
void *ptr;
@@ -195,12 +189,12 @@ __zmalloc(const char *fn, int line, size_t size)
return ptr;
}
-char *
-__xstrdup(const char *fn, int line, const char *s)
+char *__xstrdup(const char *fn, int line, const char *s)
{
char *ptr;
- assert_die(!empty_str(fn) && line > 0 && !empty_str(s), "invalid arguments");
+ assert_die(!empty_str(fn) && line > 0 && !empty_str(s),
+ "invalid arguments");
ptr = strdup(s);
if (!ptr)
@@ -208,12 +202,12 @@ __xstrdup(const char *fn, int line, const char *s)
return ptr;
}
-char *
-__xstrndup(const char *fn, int line, const char *s, size_t n)
+char *__xstrndup(const char *fn, int line, const char *s, size_t n)
{
char *ptr;
- assert_die(!empty_str(fn) && line > 0 && !empty_str(s) && n > 0, "invalid arguments");
+ assert_die(!empty_str(fn) && line > 0 && !empty_str(s) && n > 0,
+ "invalid arguments");
ptr = strndup(s, n);
if (ptr)
@@ -221,11 +215,9 @@ __xstrndup(const char *fn, int line, const char *s, size_t n)
return ptr;
}
-void
-__xfree(const char *fn, int line, void *ptr)
+void __xfree(const char *fn, int line, void *ptr)
{
assert_die(!empty_str(fn) && line > 0, "invalid arguments");
free(ptr);
}
-
diff --git a/minecctl/misc.h b/minecctl/misc.h
index 155681e..6abed5e 100644
--- a/minecctl/misc.h
+++ b/minecctl/misc.h
@@ -5,7 +5,7 @@ extern bool use_colors;
void set_use_colors();
-char *strv_join(char * const *strv);
+char *strv_join(char *const *strv);
int connect_any(struct list_head *addrs, bool may_fail);
diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c
index cf43c5e..b6a216f 100644
--- a/minecctl/rcon-commands.c
+++ b/minecctl/rcon-commands.c
@@ -16,8 +16,7 @@
#include "rcon-protocol.h"
#include "misc.h"
-static void
-send_packet(int sfd, const char *buf, size_t len)
+static void send_packet(int sfd, const char *buf, size_t len)
{
size_t off = 0;
ssize_t r;
@@ -38,8 +37,8 @@ send_packet(int sfd, const char *buf, size_t len)
}
/* Note: msg is null-terminated due to the mc protocol trailer */
-static void
-read_packet(int sfd, char *buf, size_t len, int32_t *id, int32_t *type, const char **msg)
+static void read_packet(int sfd, char *buf, size_t len, int32_t *id,
+ int32_t *type, const char **msg)
{
size_t off = 0;
ssize_t r;
@@ -69,16 +68,16 @@ read_packet(int sfd, char *buf, size_t len, int32_t *id, int32_t *type, const ch
die("Failed to parse response: %s", error);
}
-static void
-send_msg(int sfd, char *buf, size_t len, enum rcon_packet_type type,
- const char *msg, enum rcon_packet_type *rtype, const char **reply)
+static void send_msg(int sfd, char *buf, size_t len, enum rcon_packet_type type,
+ const char *msg, enum rcon_packet_type *rtype,
+ const char **reply)
{
static uint32_t rcon_packet_id = 1;
size_t plen;
int32_t id;
- if (!rcon_protocol_create_packet(buf, len, &plen,
- rcon_packet_id, type, msg))
+ if (!rcon_protocol_create_packet(buf, len, &plen, rcon_packet_id, type,
+ msg))
die("Failed to create rcon packet");
send_packet(sfd, buf, plen);
@@ -102,8 +101,7 @@ send_msg(int sfd, char *buf, size_t len, enum rcon_packet_type type,
rcon_packet_id++;
}
-static int
-rcon_login(struct cfg *cfg, struct server *server)
+static int rcon_login(struct cfg *cfg, struct server *server)
{
char buf[4096];
int32_t rtype;
@@ -121,7 +119,7 @@ rcon_login(struct cfg *cfg, struct server *server)
if (fd < 0) {
error("%s: unable to connect", server->name);
goto error;
- }
+ }
if (!server->rcon_password)
server->rcon_password = ask_password();
@@ -154,21 +152,20 @@ error:
return -1;
}
-static bool
-send_cmd(int sfd, const char *cmd)
+static bool send_cmd(int sfd, const char *cmd)
{
char buf[4096];
int32_t rtype;
const char *reply;
- send_msg(sfd, buf, sizeof(buf), RCON_PACKET_COMMAND, cmd, &rtype, &reply);
+ send_msg(sfd, buf, sizeof(buf), RCON_PACKET_COMMAND, cmd, &rtype,
+ &reply);
if (rtype != RCON_PACKET_RESPONSE) {
die("Invalid return code: %" PRIi32, rtype);
return false;
}
-
if (use_colors)
info("%s%s%s", ANSI_GREY, reply, ANSI_NORMAL);
else
@@ -177,13 +174,12 @@ send_cmd(int sfd, const char *cmd)
return true;
}
-static void
-eat_whitespace(char **pos)
+static void eat_whitespace(char **pos)
{
char *end;
size_t len;
- while(isspace(**pos))
+ while (isspace(**pos))
(*pos)++;
len = strlen(*pos);
@@ -203,24 +199,24 @@ eat_whitespace(char **pos)
#define MCTIME_PER_HOUR 1000
#define MIN_PER_HOUR 60
-static inline unsigned
-mctime_days(unsigned mctime) {
+static inline unsigned mctime_days(unsigned mctime)
+{
return (mctime / MCTIME_PER_DAY);
}
-static inline unsigned
-mctime_hh(unsigned mctime) {
+static inline unsigned mctime_hh(unsigned mctime)
+{
return (mctime % MCTIME_PER_DAY) / MCTIME_PER_HOUR;
}
-static inline unsigned
-mctime_mm(unsigned mctime) {
+static inline unsigned mctime_mm(unsigned mctime)
+{
return ((mctime % MCTIME_PER_HOUR) * MIN_PER_HOUR) / MCTIME_PER_HOUR;
}
-static bool
-get_one_status(int fd, char *buf, size_t len, const char *cmd,
- size_t argc, const char *replyscan, const char **reply, ...)
+static bool get_one_status(int fd, char *buf, size_t len, const char *cmd,
+ size_t argc, const char *replyscan,
+ const char **reply, ...)
{
int32_t rtype;
va_list ap;
@@ -240,8 +236,8 @@ get_one_status(int fd, char *buf, size_t len, const char *cmd,
return false;
}
-bool
-do_status(struct cfg *cfg) {
+bool do_status(struct cfg *cfg)
+{
char buf[4096];
char tbuf[4096];
const char *reply;
@@ -256,17 +252,17 @@ do_status(struct cfg *cfg) {
if (fd < 0)
return false;
- if (get_one_status(fd, buf, sizeof(buf), "seed", 1,
- "Seed : [ %[^]]]", &reply, tbuf))
+ if (get_one_status(fd, buf, sizeof(buf), "seed", 1, "Seed : [ %[^]]]",
+ &reply, tbuf))
info("Seed: %s", tbuf);
-
+
if (get_one_status(fd, buf, sizeof(buf), "difficulty", 1,
"The difficulty is %s", &reply, tbuf))
info("Difficulty: %s", tbuf);
if (get_one_status(fd, buf, sizeof(buf), "list", 2,
- "There are %u of a max %u players online",
- &reply, &cplayers, &maxplayers))
+ "There are %u of a max %u players online", &reply,
+ &cplayers, &maxplayers))
info("Players: %u/%u", cplayers, maxplayers);
if (get_one_status(fd, buf, sizeof(buf), "time query day", 1,
@@ -275,20 +271,23 @@ do_status(struct cfg *cfg) {
if (get_one_status(fd, buf, sizeof(buf), "time query gametime", 1,
"The time is %u", &reply, &gtime))
- info("World age: %ud:%02uh:%02um",
- mctime_days(gtime), mctime_hh(gtime), mctime_mm(gtime));
+ info("World age: %ud:%02uh:%02um", mctime_days(gtime),
+ mctime_hh(gtime), mctime_mm(gtime));
if (get_one_status(fd, buf, sizeof(buf), "time query daytime", 1,
"The time is %u", &reply, &gtime))
info("Current in-game time: %02uh:%02um",
- mctime_hh(gtime + MCTIME_OFFSET), mctime_mm(gtime + MCTIME_OFFSET));
+ mctime_hh(gtime + MCTIME_OFFSET),
+ mctime_mm(gtime + MCTIME_OFFSET));
if (get_one_status(fd, buf, sizeof(buf), "datapack list enabled", 2,
- "There are %u data packs enabled: %[^\n]", &reply, &epacks, tbuf))
+ "There are %u data packs enabled: %[^\n]", &reply,
+ &epacks, tbuf))
info("Enabled data packs (%u): %s", epacks, tbuf);
if (get_one_status(fd, buf, sizeof(buf), "datapack list available", 2,
- "There are %u data packs available : %[^\n]", &reply, &apacks, tbuf))
+ "There are %u data packs available : %[^\n]", &reply,
+ &apacks, tbuf))
info("Available data packs (%u): %s", apacks, tbuf);
else if (streq(reply, "There are no more data packs available"))
info("Available data packs: none");
@@ -308,22 +307,21 @@ do_status(struct cfg *cfg) {
return true;
}
-bool
-do_ping(_unused_ struct cfg *cfg) {
+bool do_ping(_unused_ struct cfg *cfg)
+{
die("Not implemented");
return false;
}
-static bool
-get_player_count(int fd, unsigned *current, unsigned *max)
+static bool get_player_count(int fd, unsigned *current, unsigned *max)
{
char buf[4096];
const char *reply;
unsigned c, m;
if (!get_one_status(fd, buf, sizeof(buf), "list", 2,
- "There are %u of a max %u players online",
- &reply, &c, &m))
+ "There are %u of a max %u players online", &reply,
+ &c, &m))
return false;
if (current)
@@ -335,8 +333,7 @@ get_player_count(int fd, unsigned *current, unsigned *max)
return true;
}
-static bool
-stop_one_server(struct cfg *cfg, struct server *server)
+static bool stop_one_server(struct cfg *cfg, struct server *server)
{
int fd;
bool rv;
@@ -366,16 +363,16 @@ stop_one_server(struct cfg *cfg, struct server *server)
return rv;
}
-bool
-do_stop(struct cfg *cfg) {
+bool do_stop(struct cfg *cfg)
+{
struct server *server;
server = server_get_default(cfg);
return stop_one_server(cfg, server);
}
-bool
-do_stop_all(struct cfg *cfg) {
+bool do_stop_all(struct cfg *cfg)
+{
struct server *server;
list_for_each_entry(server, &cfg->servers, list) {
@@ -386,8 +383,7 @@ do_stop_all(struct cfg *cfg) {
return true;
}
-bool
-do_rcon_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
+bool do_rcon_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
{
struct server *server;
bool rv;
@@ -399,14 +395,13 @@ do_rcon_pcount(struct cfg *cfg, unsigned *online, unsigned *max)
return false;
rv = get_player_count(fd, online, max);
-
+
close(fd);
return rv;
}
-bool
-do_console(struct cfg *cfg)
+bool do_console(struct cfg *cfg)
{
char *prompt;
char *cmd;
@@ -418,8 +413,8 @@ do_console(struct cfg *cfg)
if (fd < 0)
return false;
- prompt = alloca(strlen(program_invocation_short_name) +
- STRLEN(" (") + strlen(server->name) + STRLEN("): ") + 1);
+ prompt = alloca(strlen(program_invocation_short_name) + STRLEN(" (") +
+ strlen(server->name) + STRLEN("): ") + 1);
sprintf(prompt, "%s (%s): ", program_invocation_short_name,
server->name);
@@ -437,8 +432,8 @@ do_console(struct cfg *cfg)
continue;
}
- if (streq(tmp, "q") || streq(tmp, "quit") ||
- streq(tmp, "/q") || streq(tmp, "/quit"))
+ if (streq(tmp, "q") || streq(tmp, "quit") || streq(tmp, "/q") ||
+ streq(tmp, "/quit"))
break;
send_cmd(fd, tmp);
@@ -454,8 +449,8 @@ do_console(struct cfg *cfg)
return true;
}
-bool
-do_command(struct cfg *cfg) {
+bool do_command(struct cfg *cfg)
+{
int fd;
struct server *server;
@@ -466,4 +461,3 @@ do_command(struct cfg *cfg) {
return send_cmd(fd, cfg->cmdstr);
}
-
diff --git a/minecctl/server.c b/minecctl/server.c
index da59c8f..aca69a0 100644
--- a/minecctl/server.c
+++ b/minecctl/server.c
@@ -10,8 +10,7 @@
#include "config-parser.h"
#include "server-config-options.h"
-void
-server_read_config(struct cfg *cfg, struct server *server)
+void server_read_config(struct cfg *cfg, struct server *server)
{
char buf[4096];
size_t off = 0;
@@ -44,7 +43,8 @@ server_read_config(struct cfg *cfg, struct server *server)
off += r;
if (off == sizeof(buf) - 1)
- die("Failed to read %s: file too large", server->filename);
+ die("Failed to read %s: file too large",
+ server->filename);
}
buf[off] = '\0';
@@ -97,8 +97,7 @@ server_read_config(struct cfg *cfg, struct server *server)
verbose("mc server address not found in %s", server->filename);
}
-struct server *
-server_get_default(struct cfg *cfg)
+struct server *server_get_default(struct cfg *cfg)
{
struct server *server;
@@ -111,8 +110,7 @@ server_get_default(struct cfg *cfg)
return server;
}
-bool
-server_set_default(struct cfg *cfg, const char *name)
+bool server_set_default(struct cfg *cfg, const char *name)
{
struct server *server;
@@ -128,8 +126,7 @@ server_set_default(struct cfg *cfg, const char *name)
return false;
}
-void
-server_load_all_known(struct cfg *cfg)
+void server_load_all_known(struct cfg *cfg)
{
struct dirent *dent;
DIR *dir;
@@ -161,8 +158,7 @@ server_load_all_known(struct cfg *cfg)
closedir(dir);
}
-void
-server_free_all(struct cfg *cfg)
+void server_free_all(struct cfg *cfg)
{
struct server *server, *tmp;
@@ -170,8 +166,7 @@ server_free_all(struct cfg *cfg)
server_free(server);
}
-void
-server_free(struct server *server)
+void server_free(struct server *server)
{
struct saddr *saddr, *tmp;
@@ -192,8 +187,7 @@ server_free(struct server *server)
xfree(server);
}
-struct server *
-server_new()
+struct server *server_new()
{
struct server *server;
@@ -204,4 +198,3 @@ server_new()
return server;
}
-