mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-27 03:11:07 -04:00
Add *.plist to .gitignore and change exit code (fix #29)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
|||||||
*.project
|
*.project
|
||||||
mcrcon
|
mcrcon
|
||||||
todo
|
todo
|
||||||
|
*.plist
|
||||||
|
|||||||
24
mcrcon.c
24
mcrcon.c
@ -100,7 +100,6 @@ int run_commands(int argc, char *argv[]);
|
|||||||
rc_packet* packet_build(int id, int cmd, char *s1);
|
rc_packet* packet_build(int id, int cmd, char *s1);
|
||||||
uint8_t *packet_build_malloc(size_t *size, int32_t id, int32_t cmd, char *string);
|
uint8_t *packet_build_malloc(size_t *size, int32_t id, int32_t cmd, char *string);
|
||||||
void packet_print(rc_packet *packet);
|
void packet_print(rc_packet *packet);
|
||||||
|
|
||||||
int rcon_auth(int sock, char *passwd);
|
int rcon_auth(int sock, char *passwd);
|
||||||
int rcon_command(int sock, char *command);
|
int rcon_command(int sock, char *command);
|
||||||
|
|
||||||
@ -213,21 +212,26 @@ int main(int argc, char *argv[])
|
|||||||
// open socket
|
// open socket
|
||||||
global_rsock = net_connect(host, port);
|
global_rsock = net_connect(host, port);
|
||||||
|
|
||||||
|
int exit_code = EXIT_SUCCESS;
|
||||||
|
|
||||||
// auth & commands
|
// auth & commands
|
||||||
if (rcon_auth(global_rsock, pass))
|
if (rcon_auth(global_rsock, pass))
|
||||||
{
|
{
|
||||||
if (terminal_mode)
|
if (terminal_mode)
|
||||||
run_terminal_mode(global_rsock);
|
run_terminal_mode(global_rsock);
|
||||||
else
|
else
|
||||||
run_commands(argc, argv);
|
exit_code = run_commands(argc, argv);
|
||||||
}
|
}
|
||||||
else // auth failed
|
else // auth failed
|
||||||
|
{
|
||||||
fprintf(stdout, "Authentication failed!\n");
|
fprintf(stdout, "Authentication failed!\n");
|
||||||
|
exit_code = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
net_close(global_rsock);
|
net_close(global_rsock);
|
||||||
global_rsock = -1;
|
global_rsock = -1;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
@ -697,7 +701,7 @@ int rcon_command(int sock, char *command)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
if (packet->size > 10)
|
if (packet->size > 10)
|
||||||
packet_print(packet);
|
packet_print(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,14 +710,22 @@ int rcon_command(int sock, char *command)
|
|||||||
|
|
||||||
int run_commands(int argc, char *argv[])
|
int run_commands(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, ok = 1, ret = 0;
|
int i, ok = 1, ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
for (i = optind; i < argc && ok; i++)
|
for (i = optind; i < argc && ok; i++)
|
||||||
{
|
{
|
||||||
ok = rcon_command(global_rsock, argv[i]);
|
ok = rcon_command(global_rsock, argv[i]);
|
||||||
ret += ok;
|
if (!ok) {
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if amount of successfully sent commands
|
||||||
|
// matches amount of requested commands
|
||||||
|
if (ret == optind) ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user