optimized client command checking

This commit is contained in:
Václav Šmejkal 2024-04-27 11:42:15 +02:00
parent 26c5b4d831
commit 0150414d1b
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -162,21 +162,25 @@ int main(void)
//TODO: Remove accents //TODO: Remove accents
if (command(line, WHY2_CHAT_COMMAND_EXIT, &cmd_arg)) //USER REQUESTED PROGRAM EXIT if (strncmp(line, WHY2_CHAT_COMMAND_PREFIX, strlen(WHY2_CHAT_COMMAND_PREFIX)) == 0) //OPTIMIZE COMMANDS
{ {
printf("Exiting...\n"); //COMMANDS
exit_client(0); if (command(line, WHY2_CHAT_COMMAND_EXIT, &cmd_arg)) //USER REQUESTED PROGRAM EXIT
} else if (command(line, WHY2_CHAT_COMMAND_HELP, &cmd_arg)) {
{ printf("Exiting...\n");
printf exit_client(0);
( } else if (command(line, WHY2_CHAT_COMMAND_HELP, &cmd_arg)) //HELP CMD
"\nCommands:\n---------\n%s\n\n>>> ", {
printf
(
"\nCommands:\n---------\n%s\n\n>>> ",
WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\tExits the program.\n" WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\tExits the program.\n"
WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\tPrints out all the commands. :)" WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\tPrints out all the commands. :)"
); );
fflush(stdout); fflush(stdout);
}
} else } else
{ {
why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT