char* exec_cmd(char* cmd, t_client* client, t_data* data) { char* res; char** parse; parse = cut_cmd(data, cmd); if (channel(parse, client, data) == 1) return (NULL); else if (strcmp(parse[0], "/nick") == 0) return (nickname(data, client, parse)); else if (strcmp(parse[0], "/quit") == 0) return (quit(data, client)); else if (strcmp(parse[0], "/msg") == 0) return (msg_private(data, client, parse)); else if (strcmp(parse[0], "/server") == 0) return (quit(data, client)); else if (strcmp(parse[0], "/send_file") == 0) return (NULL); else if (strcmp(parse[0], "/accept_file") == 0) return (NULL); else if (parse[0][0] != '/') return (msg_general(data, client, parse)); else return (new_str(NULL, strcat(parse[0], " : command not found"), data)); return (res); }
int new_tree(t_cmd **cmd, t_param *param, int *j) { param->tree = init_cmd_tree(g_tree_spec[*j]); if (param->tree == NULL) return (-1); cut_cmd(param->tree, param->cmd, g_tree_spec[*j]); *cmd = param->cmd->prev; *j = 5; return (0); }
t_tree *get_tree(t_cmd *cmd_data) { t_tree *cmd_tree; if ((cmd_tree = init_cmd_tree(TYPE_CMD_SEP)) == NULL || cut_cmd(cmd_tree, cmd_data, TYPE_CMD_SEP) == -1) return (NULL); clean_tree(cmd_tree); return (cmd_tree); }