Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "server.h"
- static char (*g_cmd[13]) = {
- "FORWARD",
- "RIGHT",
- "LEFT",
- "LOOK",
- "INVENTORY",
- "BROADCAST TEXT",
- "CONNECT_NBR",
- "FORK",
- "EJECT",
- "TAKE OBJECT",
- "SET OBJECT",
- "INCANTATION",
- NULL
- };
- static void (*g_func[13])(t_env *, int, s_server *) = {
- &c_forward,
- &c_right,
- &c_left,
- &c_look,
- &c_inventory,
- &c_broadcast,
- &c_connect,
- &c_fork,
- &c_eject,
- &c_take,
- &c_set,
- &c_incantation,
- NULL
- };
- void c_set(t_env *e, int fd, s_server *s)
- {
- (void)e;
- (void)fd;
- (void)s;
- printf("set\n");
- }
- void c_incantation(t_env *e, int fd, s_server *s)
- {
- (void)e;
- (void)fd;
- (void)s;
- printf("incantation\n");
- }
- bool interpreter(t_env *e, char *str, int fd, s_server *s)
- {
- char *cmd = strdup(str);
- int i = 0;
- for (i = 0; g_cmd[i] != NULL; i++) {
- if (equal(cmd, g_cmd[i])) {
- g_func[i](e, fd, s);
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement