Add cmd_set_group (TODO: finish)
This commit is contained in:
parent
1cbc81d90b
commit
f68198cd98
2 changed files with 24 additions and 0 deletions
21
src/server.c
21
src/server.c
|
@ -308,6 +308,27 @@ int cmd_hello(int sender_id) {
|
|||
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 */
|
||||
int cmd_set_name(int sender_id, char* name){
|
||||
char buf[BUF_LEN];
|
||||
|
|
|
@ -47,6 +47,9 @@ int cmd_help(int);
|
|||
/* Function for CMD_HELLO */
|
||||
int cmd_hello(int);
|
||||
|
||||
/* Function for CMD_SET_GROUP */
|
||||
int cmd_set_group(int, char*);
|
||||
|
||||
/* Function for CMD_SET_NAME */
|
||||
int cmd_set_name(int, char*);
|
||||
|
||||
|
|
Loading…
Reference in a new issue