From ea053d96f7e89e053d4af8d39b04c5428760345f Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 23 Jun 2020 20:56:22 +0200 Subject: Big renaming, move some more functionality to shared lib --- minecctl/meson.build | 14 ++++++++++++++ minecctl/minecctl.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 minecctl/meson.build create mode 100644 minecctl/minecctl.c (limited to 'minecctl') diff --git a/minecctl/meson.build b/minecctl/meson.build new file mode 100644 index 0000000..3490338 --- /dev/null +++ b/minecctl/meson.build @@ -0,0 +1,14 @@ +minecctl_sources = [ + 'minecctl.c', +] + +minecctl_deps = [ + dep_libshared, +] + +executable( + 'minecctl', + minecctl_sources, + dependencies: minecctl_deps, +) + diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c new file mode 100644 index 0000000..e29dcef --- /dev/null +++ b/minecctl/minecctl.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +#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); +} + -- cgit v1.2.3