comparison 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
comparison
equal deleted inserted replaced
257:c413e791595a 258:ab66a2eea6a8
1 /*
2 * In this module we are going to implement TMFFS2 functionality.
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <strings.h>
9 #include <stdlib.h>
10 #include "../include/pktmux.h"
11 #include "../include/limits.h"
12 #include "localtypes.h"
13 #include "etm.h"
14 #include "tmffs2.h"
15
16 void
17 cmd_ffs2_version()
18 {
19 u_char cmdpkt[4];
20
21 cmdpkt[1] = ETM_FFS2;
22 cmdpkt[2] = TMFFS_VERSION;
23 send_etm_cmd(cmdpkt, 2);
24 }
25
26 static struct cmdtab {
27 char *cmd;
28 int minargs;
29 int maxargs;
30 void (*func)();
31 } ffs2_cmds[] = {
32 {"version", 0, 0, cmd_ffs2_version},
33 {0, 0, 0, 0}
34 };
35
36 void
37 cmd_ffs2(argc, argv)
38 char **argv;
39 {
40 struct cmdtab *tp;
41 int extargs;
42
43 for (tp = ffs2_cmds; tp->cmd; tp++)
44 if (!strcmp(tp->cmd, argv[1]))
45 break;
46 if (!tp->func) {
47 printf("error: no such ffs2 command\n");
48 return;
49 }
50 extargs = argc - 2;
51 if (extargs > tp->maxargs) {
52 printf("error: too many arguments\n");
53 return;
54 }
55 if (extargs < tp->minargs) {
56 printf("error: too few arguments\n");
57 return;
58 }
59 tp->func(argc - 1, argv + 1);
60 }