FreeCalypso > hg > freecalypso-tools
annotate rvinterf/tmsh/usercmd.c @ 173:64b37ad18f7a
e1-experiments: better test setup
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 22 Mar 2017 22:06:13 +0000 |
parents | 7b1624cdc9c0 |
children | 0f2db8baf8db |
rev | line source |
---|---|
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements fc-tmsh user command dispatch. |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <ctype.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
71
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
11 #include "exitcodes.h" |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern char usercmd[]; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
15 extern int cmd_abbr(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
16 extern int cmd_abbw(); |
168
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
17 extern int cmd_aul(); |
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
18 extern int cmd_aur(); |
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
19 extern int cmd_aus(); |
167
6e4120cdb456
fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
166
diff
changeset
|
20 extern int cmd_auw(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
21 extern int cmd_check_ffs1(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
22 extern int cmd_dieid(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
23 extern int cmd_ffs2(); |
131
cae9cb333c2c
fc-tmsh: me command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
130
diff
changeset
|
24 extern int cmd_me(); |
130
d3e2b619ff89
fc-tmsh: mpw and mpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
129
diff
changeset
|
25 extern int cmd_mpr(); |
d3e2b619ff89
fc-tmsh: mpw and mpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
129
diff
changeset
|
26 extern int cmd_mpw(); |
150
45d8c175f9b5
fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
149
diff
changeset
|
27 extern int cmd_oabbr(); |
45d8c175f9b5
fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
149
diff
changeset
|
28 extern int cmd_oabbw(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
29 extern int cmd_omr(); |
149
c81d0e9ac3b4
fc-tmsh: omw command and response handling added
Mychaela Falconia <falcon@freecalypso.org>
parents:
141
diff
changeset
|
30 extern int cmd_omw(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
31 extern int cmd_ping(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
32 extern int cmd_r8(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
33 extern int cmd_r16(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
34 extern int cmd_r32(); |
113
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
35 extern int cmd_rfe(); |
115
c41511b79b1d
fc-tmsh: rfpr command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
114
diff
changeset
|
36 extern int cmd_rfpr(); |
114
eb54195fded6
fc-tmsh: rfpw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
113
diff
changeset
|
37 extern int cmd_rfpw(); |
124
8e37317f5de0
fc-tmsh: rftr command implemented, rftw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
38 extern int cmd_rftr(); |
8e37317f5de0
fc-tmsh: rftr command implemented, rftw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
39 extern int cmd_rftw(); |
125
ca4fa5681f08
fc-tmsh: rxpw and rxpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
40 extern int cmd_rxpr(); |
ca4fa5681f08
fc-tmsh: rxpw and rxpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
41 extern int cmd_rxpw(); |
139
b5e3899b1265
fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
42 extern int cmd_save_rf_table(); |
140
e6c265bf5a6d
fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
139
diff
changeset
|
43 extern int cmd_save_rf_table_raw(); |
141
6b01d4ef85c3
fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
44 extern int cmd_save_tx_ramp(); |
113
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
45 extern int cmd_scr(); |
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
46 extern int cmd_scw(); |
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
47 extern int cmd_sr(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
48 extern int cmd_tgtreset(); |
112
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
49 extern int cmd_tm3ver(); |
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
50 extern int cmd_tminit(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
51 extern int cmd_tmpkt(); |
112
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
52 extern int cmd_tms(); |
129
bf610ca0f1b1
fc-tmsh: ttr command implemented, ttw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
53 extern int cmd_ttr(); |
bf610ca0f1b1
fc-tmsh: ttr command implemented, ttw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
54 extern int cmd_ttw(); |
126
777172bcea3c
fc-tmsh: txpw and txpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
55 extern int cmd_txpr(); |
777172bcea3c
fc-tmsh: txpw and txpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
56 extern int cmd_txpw(); |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
57 extern int cmd_version(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
58 extern int cmd_w8(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
59 extern int cmd_w16(); |
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
60 extern int cmd_w32(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 cmd_exit() |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 tty_cleanup(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 exit(0); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 static struct cmdtab { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 char *cmd; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 int minargs; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 int maxargs; |
69
2159f260ed13
fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
72 int (*func)(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } cmdtab[] = { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 {"abbr", 2, 2, cmd_abbr}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 {"abbw", 3, 3, cmd_abbw}, |
168
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
76 {"aul", 1, 1, cmd_aul}, |
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
77 {"aur", 1, 1, cmd_aur}, |
7b1624cdc9c0
fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
78 {"aus", 1, 1, cmd_aus}, |
167
6e4120cdb456
fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
166
diff
changeset
|
79 {"auw", 2, 126, cmd_auw}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 {"check-ffs1", 0, 0, cmd_check_ffs1}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 {"dieid", 0, 0, cmd_dieid}, |
68
585f63e5bca6
fc-tmsh: etmpkt command renamed to tmpkt, etmpkt retained as alias
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
82 {"etmpkt", 1, 253, cmd_tmpkt}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 {"exit", 0, 0, cmd_exit}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 {"ffs2", 1, 3, cmd_ffs2}, |
131
cae9cb333c2c
fc-tmsh: me command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
130
diff
changeset
|
85 {"me", 1, 1, cmd_me}, |
130
d3e2b619ff89
fc-tmsh: mpw and mpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
129
diff
changeset
|
86 {"mpr", 1, 1, cmd_mpr}, |
d3e2b619ff89
fc-tmsh: mpw and mpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
129
diff
changeset
|
87 {"mpw", 2, 2, cmd_mpw}, |
150
45d8c175f9b5
fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
149
diff
changeset
|
88 {"oabbr", 2, 2, cmd_oabbr}, |
45d8c175f9b5
fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
149
diff
changeset
|
89 {"oabbw", 3, 3, cmd_oabbw}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 {"omr", 2, 2, cmd_omr}, |
149
c81d0e9ac3b4
fc-tmsh: omw command and response handling added
Mychaela Falconia <falcon@freecalypso.org>
parents:
141
diff
changeset
|
91 {"omw", 2, 129, cmd_omw}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 {"ping", 0, 2, cmd_ping}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 {"quit", 0, 0, cmd_exit}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 {"r8", 1, 2, cmd_r8}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 {"r16", 1, 2, cmd_r16}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 {"r32", 1, 2, cmd_r32}, |
113
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
97 {"rfe", 1, 1, cmd_rfe}, |
115
c41511b79b1d
fc-tmsh: rfpr command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
114
diff
changeset
|
98 {"rfpr", 1, 1, cmd_rfpr}, |
114
eb54195fded6
fc-tmsh: rfpw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
113
diff
changeset
|
99 {"rfpw", 2, 3, cmd_rfpw}, |
124
8e37317f5de0
fc-tmsh: rftr command implemented, rftw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
100 {"rftr", 1, 1, cmd_rftr}, |
8e37317f5de0
fc-tmsh: rftr command implemented, rftw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
101 {"rftw", 2, 3, cmd_rftw}, |
125
ca4fa5681f08
fc-tmsh: rxpw and rxpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
102 {"rxpr", 1, 1, cmd_rxpr}, |
ca4fa5681f08
fc-tmsh: rxpw and rxpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
103 {"rxpw", 2, 2, cmd_rxpw}, |
139
b5e3899b1265
fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
104 {"save-rf-table", 1, 1, cmd_save_rf_table}, |
140
e6c265bf5a6d
fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
139
diff
changeset
|
105 {"save-rf-table-raw", 1, 1, cmd_save_rf_table_raw}, |
141
6b01d4ef85c3
fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
106 {"save-tx-ramp", 1, 1, cmd_save_tx_ramp}, |
113
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
107 {"scr", 1, 1, cmd_scr}, |
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
108 {"scw", 2, 2, cmd_scw}, |
816d91739a32
fc-tmsh: rfe, scw, scr and sr commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
109 {"sr", 2, 2, cmd_sr}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 {"tgtreset", 0, 0, cmd_tgtreset}, |
112
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
111 {"tm3ver", 1, 1, cmd_tm3ver}, |
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
112 {"tminit", 0, 0, cmd_tminit}, |
68
585f63e5bca6
fc-tmsh: etmpkt command renamed to tmpkt, etmpkt retained as alias
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
113 {"tmpkt", 1, 253, cmd_tmpkt}, |
112
2825d79bb151
fc-tmsh: beginning of L1TM command support
Mychaela Falconia <falcon@freecalypso.org>
parents:
71
diff
changeset
|
114 {"tms", 1, 1, cmd_tms}, |
129
bf610ca0f1b1
fc-tmsh: ttr command implemented, ttw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
115 {"ttr", 1, 1, cmd_ttr}, |
bf610ca0f1b1
fc-tmsh: ttr command implemented, ttw command hooked in
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
116 {"ttw", 2, 2, cmd_ttw}, |
126
777172bcea3c
fc-tmsh: txpw and txpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
117 {"txpr", 1, 1, cmd_txpr}, |
777172bcea3c
fc-tmsh: txpw and txpr implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
118 {"txpw", 2, 2, cmd_txpw}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 {"version", 1, 1, cmd_version}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 {"w8", 2, 246, cmd_w8}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 {"w16", 2, 123, cmd_w16}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 {"w32", 2, 62, cmd_w32}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 {0, 0, 0, 0} |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 }; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 void |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 dispatch_user_cmd() |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 char *argv[257]; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 char *cp, **ap; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 struct cmdtab *tp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 for (cp = usercmd; isspace(*cp); cp++) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 ; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 if (!*cp || *cp == '#') |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 argv[0] = cp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 while (*cp && !isspace(*cp)) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 cp++; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 if (*cp) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 *cp++ = '\0'; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 for (tp = cmdtab; tp->cmd; tp++) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (!strcmp(tp->cmd, argv[0])) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 break; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (!tp->func) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 printf("error: no such command\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 for (ap = argv + 1; ; ) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 while (isspace(*cp)) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 cp++; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 if (!*cp || *cp == '#') |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 break; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 if (ap - argv - 1 >= tp->maxargs) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 printf("error: too many arguments\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 if (*cp == '"') { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 *ap++ = ++cp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 while (*cp && *cp != '"') |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 cp++; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (*cp != '"') { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 printf("error: unterminated quoted string\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 *cp++ = '\0'; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } else { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 *ap++ = cp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 while (*cp && !isspace(*cp)) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 cp++; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 if (*cp) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 *cp++ = '\0'; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 if (ap - argv - 1 < tp->minargs) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 printf("error: too few arguments\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 *ap = 0; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 tp->func(ap - argv, argv); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 } |
71
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
182 |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
183 dispatch_oneshot_cmd(argc, argv) |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
184 char **argv; |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
185 { |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
186 struct cmdtab *tp; |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
187 |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
188 for (tp = cmdtab; tp->cmd; tp++) |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
189 if (!strcmp(tp->cmd, argv[0])) |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
190 break; |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
191 if (!tp->func) { |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
192 fprintf(stderr, |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
193 "error: \"%s\" is not a valid command\n", argv[0]); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
194 exit(ERROR_USAGE); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
195 } |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
196 if (argc - 1 > tp->maxargs) { |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
197 fprintf(stderr, "%s: too many arguments\n", tp->cmd); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
198 exit(ERROR_USAGE); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
199 } |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
200 if (argc - 1 < tp->minargs) { |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
201 fprintf(stderr, "%s: too few arguments\n", tp->cmd); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
202 exit(ERROR_USAGE); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
203 } |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
204 return tp->func(argc, argv); |
27c41e4b21ae
fc-tmsh one-shot operation mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
69
diff
changeset
|
205 } |