FreeCalypso > hg > freecalypso-tools
annotate rfcal/cmu200/dispatch.c @ 218:c44f31353f2f
doc/TIFFS-IVA-usage updated
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 May 2017 18:28:34 +0000 |
parents | 47d56330609d |
children |
rev | line source |
---|---|
196
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the code that dispatches client commands. |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <strings.h> |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 extern char *client_cmd_fields[]; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 extern int client_cmd_nfields; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 cmd_ping() |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 send_socket_response("+Pong\n"); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 return(0); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 } |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static struct cmdtab { |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char *cmd_kw; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 int (*handler)(); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } cmdtab[] = { |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 {"ping", cmd_ping}, |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 {0, 0} |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 }; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 dispatch_client_command() |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 { |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 struct cmdtab *tp; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (tp = cmdtab; tp->cmd_kw; tp++) |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (!strcmp(client_cmd_fields[0], tp->cmd_kw)) |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 break; |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (tp->handler) |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return tp->handler(); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 send_socket_response("-Unknown or unimplemented command\n"); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return(0); |
47d56330609d
fc-cmu200d: skeleton complete, ready to start adding meat
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |