annotate rvinterf/tmsh/ffs2.c @ 260:c146f38d2b5f

rvinterf subdir structure made a little more sensible
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 05 Feb 2014 04:02:13 +0000
parents rvinterf/etm/ffs2.c@35113b1964d3
children 7f14d7c789a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * In this module we are going to implement TMFFS2 functionality.
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
260
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 259
diff changeset
10 #include "pktmux.h"
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 259
diff changeset
11 #include "limits.h"
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "localtypes.h"
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "etm.h"
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "tmffs2.h"
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 void
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
17 cmd_ffs2_close(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
18 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
19 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
20 u_char cmdpkt[5];
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
21
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
22 cmdpkt[1] = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
23 cmdpkt[2] = TMFFS_CLOSE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
24 cmdpkt[3] = strtoul(argv[1], 0, 0);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
25 send_etm_cmd(cmdpkt, 3);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
26 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
27
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
28 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
29 cmd_ffs2_delete(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
30 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
31 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
32 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
33 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
34
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
35 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
36 if (slen >= TMFFS_STRING_SIZE) {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
37 printf("error: argument exceeds string length limit\n");
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
38 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
39 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
40 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
41 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
42 *dp++ = TMFFS_REMOVE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
43 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
44 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
45 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
46 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
47 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
48
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
49 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
50 cmd_ffs2_format(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
51 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
52 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
53 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
54 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
55
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
56 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
57 if (slen >= TMFFS_STRING_SIZE) {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
58 printf("error: argument exceeds string length limit\n");
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
59 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
60 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
61 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
62 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
63 *dp++ = TMFFS_FORMAT;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
64 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
65 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
66 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
67 /* magic is 0x2BAD, 16-bit little-endian */
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
68 *dp++ = 0xAD;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
69 *dp++ = 0x2B;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
70 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
71 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
72
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
73 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
74 cmd_ffs2_open(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
75 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
76 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
77 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
78 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
79
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
80 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
81 if (slen >= TMFFS_STRING_SIZE) {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
82 printf("error: argument exceeds string length limit\n");
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
83 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
84 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
85 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
86 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
87 *dp++ = TMFFS_OPEN;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
88 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
89 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
90 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
91 *dp++ = strtoul(argv[2], 0, 16);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
92 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
93 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
94
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
95 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
96 cmd_ffs2_preformat()
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
97 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
98 u_char cmdpkt[6];
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
99
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
100 cmdpkt[1] = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
101 cmdpkt[2] = TMFFS_PREFORMAT;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
102 /* magic is 0xDEAD, 16-bit little-endian */
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
103 cmdpkt[3] = 0xAD;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
104 cmdpkt[4] = 0xDE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
105 send_etm_cmd(cmdpkt, 4);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
106 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
107
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
108 void
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 cmd_ffs2_version()
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 u_char cmdpkt[4];
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 cmdpkt[1] = ETM_FFS2;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 cmdpkt[2] = TMFFS_VERSION;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 send_etm_cmd(cmdpkt, 2);
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 static struct cmdtab {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 char *cmd;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 int minargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 int maxargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 void (*func)();
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 } ffs2_cmds[] = {
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
124 {"close", 1, 1, cmd_ffs2_close},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
125 {"delete", 1, 1, cmd_ffs2_delete},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
126 {"format", 1, 1, cmd_ffs2_format},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
127 {"open", 2, 2, cmd_ffs2_open},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
128 {"preformat", 0, 0, cmd_ffs2_preformat},
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 {"version", 0, 0, cmd_ffs2_version},
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 {0, 0, 0, 0}
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 };
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 void
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 cmd_ffs2(argc, argv)
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 char **argv;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 struct cmdtab *tp;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 int extargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 for (tp = ffs2_cmds; tp->cmd; tp++)
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 if (!strcmp(tp->cmd, argv[1]))
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 break;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 if (!tp->func) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 printf("error: no such ffs2 command\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 extargs = argc - 2;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 if (extargs > tp->maxargs) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 printf("error: too many arguments\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 if (extargs < tp->minargs) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 printf("error: too few arguments\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 tp->func(argc - 1, argv + 1);
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }