Enable input/output buffering and fflush only explicitly

As suggested in old pull request: #39
This commit is contained in:
Tiiffi
2024-12-04 16:33:49 +02:00
parent e9f8b0e76f
commit b11429d418

View File

@ -166,10 +166,6 @@ int main(int argc, char *argv[])
if (!port) port = "25575"; if (!port) port = "25575";
if (!host) host = "localhost"; if (!host) host = "localhost";
// disable output buffering (https://github.com/Tiiffi/mcrcon/pull/39)
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
if(argc < 1 && pass == NULL) usage(); if(argc < 1 && pass == NULL) usage();
// default getopt error handler enabled // default getopt error handler enabled
@ -527,6 +523,7 @@ void packet_print(rc_packet *packet)
if (data[i - 1] != 10 && data[i - 1] != 13) { if (data[i - 1] != 10 && data[i - 1] != 13) {
putchar('\n'); putchar('\n');
} }
fflush(stdout);
} }
rc_packet *packet_build(int id, int cmd, char s[static 1]) rc_packet *packet_build(int id, int cmd, char s[static 1])
@ -685,6 +682,7 @@ int run_terminal_mode(int sock)
while (global_connection_alive) { while (global_connection_alive) {
putchar('>'); putchar('>');
fflush(stdout);
int len = get_line(command, MAX_COMMAND_LENGTH); int len = get_line(command, MAX_COMMAND_LENGTH);
if (len < 1) continue; if (len < 1) continue;