mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-28 03:41:07 -04:00
Minor cleanups.
This commit is contained in:
15
mcrcon.c
15
mcrcon.c
@ -221,13 +221,12 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
ret = run_commands(argc, argv);
|
ret = run_commands(argc, argv);
|
||||||
}
|
}
|
||||||
else /* auth failed */
|
else // auth failed
|
||||||
{
|
{
|
||||||
ret = -1;
|
ret = -1;
|
||||||
fprintf(stdout, "Authentication failed!\n");
|
fprintf(stdout, "Authentication failed!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
net_close(rsock);
|
net_close(rsock);
|
||||||
rsock = -1;
|
rsock = -1;
|
||||||
|
|
||||||
@ -607,9 +606,9 @@ uint8_t *packet_build_malloc(size_t *size, int32_t id, int32_t cmd, char *string
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* rcon packet structure */
|
/* rcon packet structure */
|
||||||
#define MAX_PACKET_SIZE (size_t) 1460 // including size member
|
#define MAX_PACKET_SIZE (size_t) 1460 // including size member
|
||||||
#define MIN_PACKET_SIZE (size_t) 10
|
#define MIN_PACKET_SIZE (size_t) 10
|
||||||
#define MAX_STRING_SIZE (size_t) (MAX_PACKET_SIZE - 2 - 3 * sizeof(int32_t))
|
#define MAX_STRING_SIZE (size_t) (MAX_PACKET_SIZE - 2 - 3 * sizeof(int32_t))
|
||||||
#define SIZEOF_PACKET(x) (size_t) (x.size + sizeof(int32_t))
|
#define SIZEOF_PACKET(x) (size_t) (x.size + sizeof(int32_t))
|
||||||
|
|
||||||
struct rcon_packet
|
struct rcon_packet
|
||||||
@ -743,7 +742,7 @@ int run_terminal_mode(int rsock)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gets line from stdin and deals with rubbish left in input buffer */
|
// gets line from stdin and deals with rubbish left in the input buffer
|
||||||
int get_line(char *buffer, int bsize)
|
int get_line(char *buffer, int bsize)
|
||||||
{
|
{
|
||||||
int ch, len;
|
int ch, len;
|
||||||
@ -754,12 +753,12 @@ int get_line(char *buffer, int bsize)
|
|||||||
if (buffer[0] == 0)
|
if (buffer[0] == 0)
|
||||||
connection_alive = 0;
|
connection_alive = 0;
|
||||||
|
|
||||||
/* remove unwanted characters from the buffer */
|
// remove unwanted characters from the buffer
|
||||||
buffer[strcspn(buffer, "\r\n")] = '\0';
|
buffer[strcspn(buffer, "\r\n")] = '\0';
|
||||||
|
|
||||||
len = strlen(buffer);
|
len = strlen(buffer);
|
||||||
|
|
||||||
/* clean input buffer if needed */
|
// clean input buffer if needed
|
||||||
if (len == bsize - 1)
|
if (len == bsize - 1)
|
||||||
while ((ch = getchar()) != '\n' && ch != EOF);
|
while ((ch = getchar()) != '\n' && ch != EOF);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user