mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-28 11:51:08 -04:00
Minor cleanups.
This commit is contained in:
9
mcrcon.c
9
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;
|
||||||
|
|
||||||
@ -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