aboutsummaryrefslogtreecommitdiff
path: root/mcping.c
diff options
context:
space:
mode:
authorPlex <thinkplex@riseup.net>2021-10-24 22:50:22 +0200
committerPlex <thinkplex@riseup.net>2021-10-24 22:50:22 +0200
commitdd1779c4c7581b0b863886371f891d9d545d6b27 (patch)
tree721db5e98337f206e3c20ef82db71ecd6fa3fede /mcping.c
parenta74a07ab26fbda8235011f2819a78a6f314a1ef2 (diff)
writeVarInt
Diffstat (limited to 'mcping.c')
-rw-r--r--mcping.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/mcping.c b/mcping.c
new file mode 100644
index 0000000..a228114
--- /dev/null
+++ b/mcping.c
@@ -0,0 +1,32 @@
+#include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include "mctypes.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc == 1) {
+ printf("Usage: mcping [ADDRESS[:PORT]]\nPings a Minecraft server using the PING protocol.\n");
+ exit(EXIT_SUCCESS);
+ }
+ int opt;
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
+ case 'h':
+ exit(EXIT_SUCCESS);
+ default:
+ break;
+ }
+ }
+ varint n;
+ n = writeVarInt(atoi(argv[1]));
+ while((*n & 0b10000000) != 0) {
+ printf("%02X ", *n);
+ n++;
+ }
+ printf("%02X ", *n);
+ printf("\n");
+ return 0;
+}