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