summaryrefslogtreecommitdiff
path: root/mcserverctl
diff options
context:
space:
mode:
Diffstat (limited to 'mcserverctl')
-rw-r--r--mcserverctl/mcserverctl.c40
-rw-r--r--mcserverctl/meson.build14
2 files changed, 54 insertions, 0 deletions
diff --git a/mcserverctl/mcserverctl.c b/mcserverctl/mcserverctl.c
new file mode 100644
index 0000000..e29dcef
--- /dev/null
+++ b/mcserverctl/mcserverctl.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include "rcon-protocol.h"
+
+int
+main(int argc, char **argv)
+{
+ char buf[4096];
+ size_t len;
+ int32_t id, type;
+ const char *msg, *error;
+
+ fprintf(stderr, "Started\n");
+
+ if (!rcon_protocol_create_packet(buf, sizeof(buf), &len,
+ 1, RCON_PACKET_LOGIN,
+ "test")) {
+ fprintf(stderr, "Failed to create packet\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (!rcon_protocol_packet_complete(buf, len)) {
+ fprintf(stderr, "Packet not complete\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (!rcon_protocol_read_packet(buf, len, &id, &type, &msg, &error)) {
+ fprintf(stderr, "Packet parsing failed: %s\n", error);
+ exit(EXIT_FAILURE);
+ }
+
+ fprintf(stderr, "Packet - id: %" PRIi32 ", type: %" PRIi32 ", msg: %s\n",
+ id, type, msg);
+
+ exit(EXIT_SUCCESS);
+}
+
diff --git a/mcserverctl/meson.build b/mcserverctl/meson.build
new file mode 100644
index 0000000..4e960b7
--- /dev/null
+++ b/mcserverctl/meson.build
@@ -0,0 +1,14 @@
+mcserverctl_sources = [
+ 'mcserverctl.c',
+]
+
+mcserverctl_deps = [
+ dep_libshared,
+]
+
+executable(
+ 'mcserverctl',
+ mcserverctl_sources,
+ dependencies: mcserverctl_deps,
+)
+