Add cmd_set_group (TODO: finish)

This commit is contained in:
flyingscorpio@clevo 2022-11-04 15:11:46 +01:00
parent 1cbc81d90b
commit f68198cd98
2 changed files with 24 additions and 0 deletions

View file

@ -308,6 +308,27 @@ int cmd_hello(int sender_id) {
return 0; return 0;
} }
/* Function for CMD_SET_GROUP */
int cmd_set_group(int sender_id, char* name) {
int group_id;
if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) {
fprintf(stderr, "Received invalid sender id \"%d\"\n", sender_id);
return -1;
}
if ((strlen(name) == 0) || (strlen(name) > MAX_NAME_LENGTH)) {
fprintf(stderr, "Received invalid name \"%s\"\n", name);
return -1;
}
// TODO: finish get_group_id_from_name
group_id = 0;
groups[group_id].clients[sender_id] = 1;
return 0;
}
/* 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];

View file

@ -47,6 +47,9 @@ int cmd_help(int);
/* Function for CMD_HELLO */ /* Function for CMD_HELLO */
int cmd_hello(int); int cmd_hello(int);
/* Function for CMD_SET_GROUP */
int cmd_set_group(int, char*);
/* Function for CMD_SET_NAME */ /* Function for CMD_SET_NAME */
int cmd_set_name(int, char*); int cmd_set_name(int, char*);