1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
}
|