FreeCalypso > hg > fc-rfcal-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:bd62be88259d |
|---|---|
| 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 } |
