diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/rcon.h | 31 |
2 files changed, 24 insertions, 9 deletions
@@ -122,7 +122,7 @@ int connect_socket ( char* _host, char* _port ) { } void print_help ( char* _progname ) { - printf( + fprintf( stderr, "Minecraft RCON client\n" "Usage:\n" " %s HOST PORT PASSWORD COMMAND ...", @@ -12,7 +12,9 @@ * 2-byte pad byte^2 Two null bytes * * sizeof int: 4B - * */ + */ + +#pragma once #include <stdint.h> #include <stdlib.h> @@ -43,17 +45,30 @@ typedef struct rcon_packet_s { uint32_t payload_len; } rcon_packet_t; -int rcon_parse_packet ( rcon_packet_t* _packet, char* _buffer, uint32_t _len ); - -int rcon_construct_packet ( char* _buffer, uint32_t _len, rcon_packet_t* _packet ); - +/** + * Authenticate RCON connection + */ int rcon_login ( int _socket, const char* _password ); +/** + * Send command via authenticated RCON connection + * Result is written to _output. + */ int rcon_command ( char** _output, int _socket, const char* _command ); -int rcon_recv_packet ( int _socket, rcon_packet_t* _packet, int _timeout_msecs ); +/** + * Get rcon_* return code string representation + */ +const char* rcon_strerror ( int _errno ); -int rcon_send_packet ( int _socket, rcon_packet_t* _packet ); +/** + * rcon_login and rcon_command are wrappers around the following functions + */ -const char* rcon_strerror ( int _errno ); +int rcon_parse_packet ( rcon_packet_t* _packet, char* _buffer, uint32_t _len ); + +int rcon_construct_packet ( char* _buffer, uint32_t _len, rcon_packet_t* _packet ); +int rcon_recv_packet ( int _socket, rcon_packet_t* _packet, int _timeout_msecs ); + +int rcon_send_packet ( int _socket, rcon_packet_t* _packet ); |