FreeCalypso > hg > freecalypso-sw
diff rvinterf/etm/ffs2.c @ 258:ab66a2eea6a8
fc-tmsh: beginning of ffs2 command dispatch
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 04 Feb 2014 07:43:12 +0000 |
parents | |
children | 35113b1964d3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etm/ffs2.c Tue Feb 04 07:43:12 2014 +0000 @@ -0,0 +1,60 @@ +/* + * In this module we are going to implement TMFFS2 functionality. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "../include/pktmux.h" +#include "../include/limits.h" +#include "localtypes.h" +#include "etm.h" +#include "tmffs2.h" + +void +cmd_ffs2_version() +{ + u_char cmdpkt[4]; + + cmdpkt[1] = ETM_FFS2; + cmdpkt[2] = TMFFS_VERSION; + send_etm_cmd(cmdpkt, 2); +} + +static struct cmdtab { + char *cmd; + int minargs; + int maxargs; + void (*func)(); +} ffs2_cmds[] = { + {"version", 0, 0, cmd_ffs2_version}, + {0, 0, 0, 0} +}; + +void +cmd_ffs2(argc, argv) + char **argv; +{ + struct cmdtab *tp; + int extargs; + + for (tp = ffs2_cmds; tp->cmd; tp++) + if (!strcmp(tp->cmd, argv[1])) + break; + if (!tp->func) { + printf("error: no such ffs2 command\n"); + return; + } + extargs = argc - 2; + if (extargs > tp->maxargs) { + printf("error: too many arguments\n"); + return; + } + if (extargs < tp->minargs) { + printf("error: too few arguments\n"); + return; + } + tp->func(argc - 1, argv + 1); +}