Minor changes

This commit is contained in:
flyingscorpio@clevo 2022-11-04 23:15:13 +01:00
parent ea9b2a28dd
commit 5c06da2b6d

View file

@ -373,7 +373,7 @@ int cmd_set_group(int sender_id, char* name) {
} }
/* Function for CMD_SET_NAME */ /* Function for CMD_SET_NAME */
int cmd_set_name(int sender_id, char* name){ int cmd_set_name(int sender_id, char* name) {
char buf[BUF_LEN]; char buf[BUF_LEN];
if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) { if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) {
@ -384,7 +384,7 @@ int cmd_set_name(int sender_id, char* name){
fprintf(stderr, "WARNING: Received invalid name \"%s\"\n", name); fprintf(stderr, "WARNING: Received invalid name \"%s\"\n", name);
return -1; return -1;
} }
if (get_client_id_from_name(name) < MAX_CLIENTS){ if (get_client_id_from_name(name) < MAX_CLIENTS) {
fprintf(stderr, "WARNING: Name \"%s\" is already used\n", name); fprintf(stderr, "WARNING: Name \"%s\" is already used\n", name);
sprintf(buf, "Name \"%s\" is already used !\n", name); sprintf(buf, "Name \"%s\" is already used !\n", name);
cmd_send_message(SERVER_ID, sender_id, buf); cmd_send_message(SERVER_ID, sender_id, buf);
@ -401,7 +401,7 @@ int cmd_set_name(int sender_id, char* name){
} }
/* Function for CMD_GET_NAME */ /* Function for CMD_GET_NAME */
int cmd_get_name(int sender_id){ int cmd_get_name(int sender_id) {
char buf[BUF_LEN]; char buf[BUF_LEN];
if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) { if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) {
@ -605,7 +605,7 @@ void *Dispatcher(void *arg) {
printf("cmd_send_message (from %d)\n", sender_id); printf("cmd_send_message (from %d)\n", sender_id);
/* Extract receiver_id */ /* Extract receiver_id */
if ((token = strtok_r(rest, " ", &rest)) == NULL ) { if ((token = strtok_r(rest, " ", &rest)) == NULL) {
fprintf(stderr, "ERROR: strtok_r didn't return a token\n"); fprintf(stderr, "ERROR: strtok_r didn't return a token\n");
error_message = "WARNING: Syntax error: missing arguments\n"; error_message = "WARNING: Syntax error: missing arguments\n";
cmd_send_message(SERVER_ID, sender_id, error_message); cmd_send_message(SERVER_ID, sender_id, error_message);