comparison rfcal/cmu200/dispatch.c @ 196:47d56330609d

fc-cmu200d: skeleton complete, ready to start adding meat
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Apr 2017 02:17:04 +0000
parents
children
comparison
equal deleted inserted replaced
195:db9ee7745cdd 196:47d56330609d
1 /*
2 * This module contains the code that dispatches client commands.
3 */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <strings.h>
9
10 extern char *client_cmd_fields[];
11 extern int client_cmd_nfields;
12
13 cmd_ping()
14 {
15 send_socket_response("+Pong\n");
16 return(0);
17 }
18
19 static struct cmdtab {
20 char *cmd_kw;
21 int (*handler)();
22 } cmdtab[] = {
23 {"ping", cmd_ping},
24 {0, 0}
25 };
26
27 dispatch_client_command()
28 {
29 struct cmdtab *tp;
30
31 for (tp = cmdtab; tp->cmd_kw; tp++)
32 if (!strcmp(client_cmd_fields[0], tp->cmd_kw))
33 break;
34 if (tp->handler)
35 return tp->handler();
36 send_socket_response("-Unknown or unimplemented command\n");
37 return(0);
38 }