diff options
-rw-r--r-- | config-parser.c | 2 | ||||
-rw-r--r-- | mcserverctl.c | 41 | ||||
-rw-r--r-- | meson.build | 10 | ||||
-rw-r--r-- | rcon-protocol.h | 3 |
4 files changed, 54 insertions, 2 deletions
diff --git a/config-parser.c b/config-parser.c index 0d38789..ffed7f1 100644 --- a/config-parser.c +++ b/config-parser.c @@ -9,9 +9,7 @@ #include <inttypes.h> #include "main.h" -#include "uring.h" #include "config-parser.h" -#include "server.h" static void eat_whitespace_and_comments(char **pos) diff --git a/mcserverctl.c b/mcserverctl.c new file mode 100644 index 0000000..8a799a2 --- /dev/null +++ b/mcserverctl.c @@ -0,0 +1,41 @@ +#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/meson.build b/meson.build index 3d82301..eb446fe 100644 --- a/meson.build +++ b/meson.build @@ -50,6 +50,11 @@ mcproxy_sources = [ 'utils.c' ] +mcserverctl_sources = [ + 'mcserverctl.c', + 'rcon-protocol.c', +] + executable('mcproxy', mcproxy_sources, link_args: [ '-lanl' ], @@ -62,3 +67,8 @@ executable('mcproxy', ], ) +executable('mcserverctl', + mcserverctl_sources, + include_directories : configuration_inc, +) + diff --git a/rcon-protocol.h b/rcon-protocol.h index fd83d79..35997c4 100644 --- a/rcon-protocol.h +++ b/rcon-protocol.h @@ -1,6 +1,9 @@ #ifndef foorconprotocolhfoo #define foorconprotocolhfoo +#include <stdbool.h> +#include <stdint.h> + enum rcon_packet_type { RCON_PACKET_LOGIN = 3, RCON_PACKET_LOGIN_OK = 2, |