FreeCalypso > hg > fc-pcsc-tools
annotate simtool/dispatch.c @ 228:a93de68711b8
original README is now README.old
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 18:16:27 +0000 |
parents | e3059d58ec93 |
children |
rev | line source |
---|---|
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the command dispatch for fc-simtool |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <ctype.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <strings.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 extern int cmd_a38(); |
121
8e70ee7c194f
fc-simtool & fc-uicc-tool: raw apdu command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
117
diff
changeset
|
12 extern int cmd_apdu(); |
145
c2889812788e
fc-simtool bfsearch implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
137
diff
changeset
|
13 extern int cmd_bfsearch(); |
149
26d7a8815515
fc-simtool bfsearch-full implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
14 extern int cmd_bfsearch_full(); |
132
d991944aa5f3
fc-simtool: local cd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
15 extern int cmd_cd(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern int cmd_change_chv(); |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
17 extern int cmd_disable_chv1(); |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
18 extern int cmd_disable_chv1_rpt(); |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
19 extern int cmd_enable_chv1(); |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
20 extern int cmd_enable_chv1_rpt(); |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
21 extern int cmd_envelope(); |
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
22 extern int cmd_envelope_imm(); |
193
bc127ba44488
fc-simtool erase-file command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
187
diff
changeset
|
23 extern int cmd_erase_file(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 extern int cmd_exec(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 extern int cmd_fix_sysmo_msisdn(); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
26 extern int cmd_fplmn_dump(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
27 extern int cmd_fplmn_erase(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
28 extern int cmd_fplmn_erase_all(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
29 extern int cmd_fplmn_write(); |
199
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
198
diff
changeset
|
30 extern int cmd_fplmn_write_list(); |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
31 extern int cmd_get_response(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 extern int cmd_grcard1_set_adm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 extern int cmd_grcard1_set_ki(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 extern int cmd_grcard1_set_pin(); |
187
36e7fc58f065
GrcardSIM2 ADM5 setting command is now grcard2-set-adm5
Mychaela Falconia <falcon@freecalypso.org>
parents:
184
diff
changeset
|
35 extern int cmd_grcard2_set_adm5(); |
36e7fc58f065
GrcardSIM2 ADM5 setting command is now grcard2-set-adm5
Mychaela Falconia <falcon@freecalypso.org>
parents:
184
diff
changeset
|
36 extern int cmd_grcard2_set_adm5_hex(); |
220
e07de8a9cedf
fc-simtool grcard2-set-comp128 command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
218
diff
changeset
|
37 extern int cmd_grcard2_set_comp128(); |
221
e3059d58ec93
fc-simtool grcard2-set-ki command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
38 extern int cmd_grcard2_set_ki(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 extern int cmd_grcard2_set_pin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 extern int cmd_grcard2_set_puk(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 extern int cmd_grcard2_set_super(); |
74
8562d8508cf2
grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
42 extern int cmd_grcard2_set_super_hex(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 extern int cmd_iccid(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 extern int cmd_imsi(); |
184
8d073ff62c48
fc-simtool: imsi command does higher-level parsing,
Mychaela Falconia <falcon@freecalypso.org>
parents:
183
diff
changeset
|
45 extern int cmd_imsi_raw(); |
125
e5d534fa5924
fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
46 extern int cmd_inval_adn(); |
76
0b29c0d19db4
fc-simtool: dump-lnd command renamed to lnd-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
47 extern int cmd_lnd_dump(); |
84
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
48 extern int cmd_lnd_erase(); |
88
ae831b21ef77
lnd-restore command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
87
diff
changeset
|
49 extern int cmd_lnd_restore(); |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
82
diff
changeset
|
50 extern int cmd_lnd_write(); |
54
2d1679c7975b
fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
51 extern int cmd_opl_dump(); |
218
f376ba028311
fc-simtool opl-erase and opl-write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
216
diff
changeset
|
52 extern int cmd_opl_erase(); |
f376ba028311
fc-simtool opl-erase and opl-write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
216
diff
changeset
|
53 extern int cmd_opl_write(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 extern int cmd_pb_dump(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 extern int cmd_pb_dump_rec(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 extern int cmd_pb_erase(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 extern int cmd_pb_erase_one(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 extern int cmd_pb_erase_range(); |
87
bc862d41f96b
pb-restore command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
84
diff
changeset
|
59 extern int cmd_pb_restore(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 extern int cmd_pb_update(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 extern int cmd_pb_update_imm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 extern int cmd_pb_update_imm_hex(); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
63 extern int cmd_plmnsel_dump(); |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
64 extern int cmd_plmnsel_erase(); |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
65 extern int cmd_plmnsel_erase_all(); |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
88
diff
changeset
|
66 extern int cmd_plmnsel_write(); |
198
3bde063234aa
fc-simtool plmnsel-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
193
diff
changeset
|
67 extern int cmd_plmnsel_write_list(); |
50
dc8a2e6fa03e
fc-simtool pnn-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
68 extern int cmd_pnn_dump(); |
216
cd66e13eccf3
fc-simtool pnn-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
215
diff
changeset
|
69 extern int cmd_pnn_erase(); |
215
3a2f43460582
fc-simtool pnn-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
211
diff
changeset
|
70 extern int cmd_pnn_write(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 extern int cmd_readbin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 extern int cmd_readef(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 extern int cmd_readrec(); |
125
e5d534fa5924
fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
74 extern int cmd_rehab_adn(); |
126
7faec607500f
rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
75 extern int cmd_rehab_imsi(); |
7faec607500f
rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
76 extern int cmd_rehab_loci(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 extern int cmd_restore_file(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 extern int cmd_savebin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 extern int cmd_save_sms_bin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 extern int cmd_select(); |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
81 extern int cmd_sim_resp(); |
42
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
82 extern int cmd_sms_erase_all(); |
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
83 extern int cmd_sms_erase_one(); |
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
84 extern int cmd_sms_erase_range(); |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
85 extern int cmd_smsp_dump(); |
40
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
86 extern int cmd_smsp_erase_all(); |
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
87 extern int cmd_smsp_erase_one(); |
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
88 extern int cmd_smsp_erase_range(); |
39
2467b7acad1f
fc-simtool smsp-restore implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
38
diff
changeset
|
89 extern int cmd_smsp_restore(); |
44
f4eb1e83b4b3
fc-simtool smsp-set command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
90 extern int cmd_smsp_set(); |
45
5bca197e7495
fc-simtool smsp-set-tag command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
91 extern int cmd_smsp_set_tag(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 extern int cmd_spn(); |
59
c56e63a8725d
fc-simtool sst-dump command shortened to just sst
Mychaela Falconia <falcon@freecalypso.org>
parents:
58
diff
changeset
|
93 extern int cmd_sst(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 extern int cmd_telecom_sum(); |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
95 extern int cmd_terminal_profile(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 extern int cmd_uicc_dir(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 extern int cmd_unblock_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 extern int cmd_update_bin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 extern int cmd_update_bin_imm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 extern int cmd_update_rec(); |
204
a462012c9e67
fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
203
diff
changeset
|
101 extern int cmd_update_rec_fill(); |
203
647267e39c21
fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
202
diff
changeset
|
102 extern int cmd_update_rec_imm(); |
61
633033af6fb8
fc-simtool user-sum command implemented,
Mychaela Falconia <falcon@freecalypso.org>
parents:
59
diff
changeset
|
103 extern int cmd_user_sum(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 extern int cmd_verify_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 extern int cmd_verify_ext(); |
47
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
45
diff
changeset
|
106 extern int cmd_verify_hex(); |
122
c0cd0d4635bb
fc-simtool verify-sjs1-adm1 command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
107 extern int cmd_verify_sjs1_adm1(); |
210
9797417ececa
fc-simtool write-acc command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
209
diff
changeset
|
108 extern int cmd_write_acc(); |
68
105aa3d1a494
fc-simtool write-iccid command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
67
diff
changeset
|
109 extern int cmd_write_iccid(); |
182
f4edccd4b583
fc-simtool: write-iccid-sh{18,19} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
172
diff
changeset
|
110 extern int cmd_write_iccid_sh18(); |
f4edccd4b583
fc-simtool: write-iccid-sh{18,19} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
172
diff
changeset
|
111 extern int cmd_write_iccid_sh19(); |
67
9ff7ee99346f
forgot to hook in newly added write-imsi command
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
112 extern int cmd_write_imsi(); |
183
2545dd27ca38
fc-simtool write-imsi-sh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
182
diff
changeset
|
113 extern int cmd_write_imsi_sh(); |
211
31cd62f91522
fc-simtool write-spn command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
210
diff
changeset
|
114 extern int cmd_write_spn(); |
209
eb16c8841486
fc-simtool write-sst command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
115 extern int cmd_write_sst(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 |
124
d0d1c0b35831
fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
117 extern int current_ef_inval(); |
d0d1c0b35831
fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
118 extern int current_ef_rehab(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 extern int good_exit(); |
29
d368051576d0
fc-simtool & fc-uicc-tool: add explicit atr command
Mychaela Falconia <falcon@freecalypso.org>
parents:
1
diff
changeset
|
120 extern int retrieve_atr(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 static struct cmdtab { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 char *cmd; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 int minargs; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 int maxargs; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
126 int allow_redir; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 int (*func)(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } cmdtab[] = { |
108
e17940d7ce35
fc-simtool a38: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
107
diff
changeset
|
129 {"a38", 1, 1, 1, cmd_a38}, |
121
8e70ee7c194f
fc-simtool & fc-uicc-tool: raw apdu command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
117
diff
changeset
|
130 {"apdu", 1, 1, 0, cmd_apdu}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
131 {"atr", 0, 0, 0, retrieve_atr}, |
147
dcbabc398c6a
increase max number of skip-ID arguments for bfsearch
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
132 {"bfsearch", 1, 18, 1, cmd_bfsearch}, |
149
26d7a8815515
fc-simtool bfsearch-full implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
133 {"bfsearch-full", 0, 0, 1, cmd_bfsearch_full}, |
154
6d93a51f01dc
fc-simtool: bfsearch-full is also bfsearch-mf
Mychaela Falconia <falcon@freecalypso.org>
parents:
149
diff
changeset
|
134 {"bfsearch-mf", 0, 0, 1, cmd_bfsearch_full}, |
132
d991944aa5f3
fc-simtool: local cd command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
135 {"cd", 1, 1, 0, cmd_cd}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
136 {"change-chv1", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
137 {"change-chv2", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
138 {"change-pin1", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
139 {"change-pin2", 2, 2, 0, cmd_change_chv}, |
124
d0d1c0b35831
fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
140 {"cur-ef-inval", 0, 0, 0, current_ef_inval}, |
d0d1c0b35831
fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
122
diff
changeset
|
141 {"cur-ef-rehab", 0, 0, 0, current_ef_rehab}, |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
142 {"disable-chv1", 1, 1, 0, cmd_disable_chv1}, |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
143 {"disable-chv1-rpt", 1, 1, 0, cmd_disable_chv1_rpt}, |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
144 {"disable-pin1", 1, 1, 0, cmd_disable_chv1}, |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
145 {"disable-pin1-rpt", 1, 1, 0, cmd_disable_chv1_rpt}, |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
146 {"enable-chv1", 1, 1, 0, cmd_enable_chv1}, |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
147 {"enable-chv1-rpt", 1, 1, 0, cmd_enable_chv1_rpt}, |
168
afd6a805c518
simtool code: rename CHV1 {dis,en}able functions more consistently
Mychaela Falconia <falcon@freecalypso.org>
parents:
167
diff
changeset
|
148 {"enable-pin1", 1, 1, 0, cmd_enable_chv1}, |
166
febcbc6082df
fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
154
diff
changeset
|
149 {"enable-pin1-rpt", 1, 1, 0, cmd_enable_chv1_rpt}, |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
150 {"envelope", 1, 1, 0, cmd_envelope}, |
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
151 {"envelope-imm", 1, 1, 0, cmd_envelope_imm}, |
193
bc127ba44488
fc-simtool erase-file command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
187
diff
changeset
|
152 {"erase-file", 1, 2, 0, cmd_erase_file}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
153 {"exec", 1, 1, 0, cmd_exec}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
154 {"exit", 0, 0, 0, good_exit}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
155 {"fix-sysmo-msisdn", 0, 0, 0, cmd_fix_sysmo_msisdn}, |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
108
diff
changeset
|
156 {"fplmn-dump", 0, 0, 1, cmd_fplmn_dump}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
157 {"fplmn-erase", 1, 2, 0, cmd_fplmn_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
158 {"fplmn-erase-all", 0, 0, 0, cmd_fplmn_erase_all}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
159 {"fplmn-write", 2, 2, 0, cmd_fplmn_write}, |
199
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
198
diff
changeset
|
160 {"fplmn-write-list", 1, 1, 0, cmd_fplmn_write_list}, |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
161 {"get-response", 1, 1, 1, cmd_get_response}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
162 {"grcard1-set-adm1", 2, 2, 0, cmd_grcard1_set_adm}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
163 {"grcard1-set-adm2", 2, 2, 0, cmd_grcard1_set_adm}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
164 {"grcard1-set-ki", 1, 1, 0, cmd_grcard1_set_ki}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
165 {"grcard1-set-pin1", 2, 2, 0, cmd_grcard1_set_pin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
166 {"grcard1-set-pin2", 2, 2, 0, cmd_grcard1_set_pin}, |
187
36e7fc58f065
GrcardSIM2 ADM5 setting command is now grcard2-set-adm5
Mychaela Falconia <falcon@freecalypso.org>
parents:
184
diff
changeset
|
167 {"grcard2-set-adm5", 1, 1, 0, cmd_grcard2_set_adm5}, |
36e7fc58f065
GrcardSIM2 ADM5 setting command is now grcard2-set-adm5
Mychaela Falconia <falcon@freecalypso.org>
parents:
184
diff
changeset
|
168 {"grcard2-set-adm5-hex", 1, 1, 0, cmd_grcard2_set_adm5_hex}, |
220
e07de8a9cedf
fc-simtool grcard2-set-comp128 command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
218
diff
changeset
|
169 {"grcard2-set-comp128", 1, 1, 0, cmd_grcard2_set_comp128}, |
221
e3059d58ec93
fc-simtool grcard2-set-ki command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
220
diff
changeset
|
170 {"grcard2-set-ki", 1, 1, 0, cmd_grcard2_set_ki}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
171 {"grcard2-set-pin1", 1, 1, 0, cmd_grcard2_set_pin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
172 {"grcard2-set-pin2", 1, 1, 0, cmd_grcard2_set_pin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
173 {"grcard2-set-puk1", 1, 1, 0, cmd_grcard2_set_puk}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
174 {"grcard2-set-puk2", 1, 1, 0, cmd_grcard2_set_puk}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
175 {"grcard2-set-super", 1, 1, 0, cmd_grcard2_set_super}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
176 {"grcard2-set-super-hex", 1, 1, 0, cmd_grcard2_set_super_hex}, |
110
2aa92dfcb4b5
fc-simtool iccid, imsi, spn: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
177 {"iccid", 0, 0, 1, cmd_iccid}, |
2aa92dfcb4b5
fc-simtool iccid, imsi, spn: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
178 {"imsi", 0, 0, 1, cmd_imsi}, |
184
8d073ff62c48
fc-simtool: imsi command does higher-level parsing,
Mychaela Falconia <falcon@freecalypso.org>
parents:
183
diff
changeset
|
179 {"imsi-raw", 0, 0, 1, cmd_imsi_raw}, |
125
e5d534fa5924
fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
180 {"inval-adn", 0, 0, 0, cmd_inval_adn}, |
111
869488ef86b6
pb-dump command family reworked for new output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
181 {"lnd-dump", 0, 0, 1, cmd_lnd_dump}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
182 {"lnd-erase", 0, 0, 0, cmd_lnd_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
183 {"lnd-restore", 1, 1, 0, cmd_lnd_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
184 {"lnd-write", 1, 2, 0, cmd_lnd_write}, |
112
440a4582d2a5
fc-simtool opl-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
111
diff
changeset
|
185 {"opl-dump", 0, 0, 1, cmd_opl_dump}, |
218
f376ba028311
fc-simtool opl-erase and opl-write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
216
diff
changeset
|
186 {"opl-erase", 1, 2, 0, cmd_opl_erase}, |
f376ba028311
fc-simtool opl-erase and opl-write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
216
diff
changeset
|
187 {"opl-write", 5, 5, 0, cmd_opl_write}, |
111
869488ef86b6
pb-dump command family reworked for new output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
188 {"pb-dump", 1, 1, 1, cmd_pb_dump}, |
869488ef86b6
pb-dump command family reworked for new output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
189 {"pb-dump-rec", 2, 3, 1, cmd_pb_dump_rec}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
190 {"pb-erase", 1, 1, 0, cmd_pb_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
191 {"pb-erase-one", 2, 2, 0, cmd_pb_erase_one}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
192 {"pb-erase-range", 3, 3, 0, cmd_pb_erase_range}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
193 {"pb-restore", 2, 2, 0, cmd_pb_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
194 {"pb-update", 2, 2, 0, cmd_pb_update}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
195 {"pb-update-imm", 3, 4, 0, cmd_pb_update_imm}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
196 {"pb-update-imm-hex", 4, 4, 0, cmd_pb_update_imm_hex}, |
113
32acef9d20ff
fc-simtool plmnsel-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
112
diff
changeset
|
197 {"plmnsel-dump", 0, 0, 1, cmd_plmnsel_dump}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
198 {"plmnsel-erase", 1, 2, 0, cmd_plmnsel_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
199 {"plmnsel-erase-all", 0, 0, 0, cmd_plmnsel_erase_all}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
200 {"plmnsel-write", 2, 2, 0, cmd_plmnsel_write}, |
198
3bde063234aa
fc-simtool plmnsel-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
193
diff
changeset
|
201 {"plmnsel-write-list", 1, 1, 0, cmd_plmnsel_write_list}, |
114
2c07684a3980
fc-simtool pnn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
113
diff
changeset
|
202 {"pnn-dump", 0, 0, 1, cmd_pnn_dump}, |
216
cd66e13eccf3
fc-simtool pnn-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
215
diff
changeset
|
203 {"pnn-erase", 1, 2, 0, cmd_pnn_erase}, |
215
3a2f43460582
fc-simtool pnn-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
211
diff
changeset
|
204 {"pnn-write", 2, 3, 0, cmd_pnn_write}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
205 {"quit", 0, 0, 0, good_exit}, |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
206 {"readbin", 2, 2, 1, cmd_readbin}, |
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
207 {"readef", 1, 1, 1, cmd_readef}, |
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
208 {"readrec", 1, 2, 1, cmd_readrec}, |
125
e5d534fa5924
fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
124
diff
changeset
|
209 {"rehab-adn", 0, 0, 0, cmd_rehab_adn}, |
126
7faec607500f
rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
210 {"rehab-imsi", 0, 0, 0, cmd_rehab_imsi}, |
7faec607500f
rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
125
diff
changeset
|
211 {"rehab-loci", 0, 0, 0, cmd_rehab_loci}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
212 {"restore-file", 2, 2, 0, cmd_restore_file}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
213 {"savebin", 2, 2, 0, cmd_savebin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
214 {"save-sms-bin", 1, 1, 0, cmd_save_sms_bin}, |
172
e7e0d8c06654
fc-simtool: support output redirection in select command
Mychaela Falconia <falcon@freecalypso.org>
parents:
168
diff
changeset
|
215 {"select", 1, 1, 1, cmd_select}, |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
216 {"sim-resp", 0, 0, 1, cmd_sim_resp}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
217 {"sms-erase-all", 0, 0, 0, cmd_sms_erase_all}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
218 {"sms-erase-one", 1, 1, 0, cmd_sms_erase_one}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
219 {"sms-erase-range", 2, 2, 0, cmd_sms_erase_range}, |
115
f1ea981ab225
fc-simtool smsp-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
114
diff
changeset
|
220 {"smsp-dump", 0, 0, 1, cmd_smsp_dump}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
221 {"smsp-erase-all", 0, 0, 0, cmd_smsp_erase_all}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
222 {"smsp-erase-one", 1, 1, 0, cmd_smsp_erase_one}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
223 {"smsp-erase-range", 2, 2, 0, cmd_smsp_erase_range}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
224 {"smsp-restore", 1, 1, 0, cmd_smsp_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
225 {"smsp-set", 2, 6, 0, cmd_smsp_set}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
226 {"smsp-set-tag", 3, 7, 0, cmd_smsp_set_tag}, |
110
2aa92dfcb4b5
fc-simtool iccid, imsi, spn: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
227 {"spn", 0, 0, 1, cmd_spn}, |
116
9c16cf1a79af
fc-simtool sst: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
228 {"sst", 0, 0, 1, cmd_sst}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
229 {"telecom-sum", 0, 0, 0, cmd_telecom_sum}, |
137
277c66de296f
fc-simtool: added STK test commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
230 {"terminal-profile", 1, 1, 0, cmd_terminal_profile}, |
106
dcfec53643c5
EF_DIR dump commands support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
104
diff
changeset
|
231 {"uicc-dir", 0, 0, 1, cmd_uicc_dir}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
232 {"unblock-chv1", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
233 {"unblock-chv2", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
234 {"unblock-pin1", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
235 {"unblock-pin2", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
236 {"update-bin", 2, 2, 0, cmd_update_bin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
237 {"update-bin-imm", 2, 2, 0, cmd_update_bin_imm}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
238 {"update-rec", 2, 2, 0, cmd_update_rec}, |
204
a462012c9e67
fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
203
diff
changeset
|
239 {"update-rec-fill", 2, 2, 0, cmd_update_rec_fill}, |
203
647267e39c21
fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
202
diff
changeset
|
240 {"update-rec-imm", 2, 2, 0, cmd_update_rec_imm}, |
117
b89bc690dec4
fc-simtool user-sum: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
241 {"user-sum", 0, 0, 1, cmd_user_sum}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
242 {"verify-chv1", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
243 {"verify-chv2", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
244 {"verify-ext", 2, 2, 0, cmd_verify_ext}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
245 {"verify-hex", 2, 2, 0, cmd_verify_hex}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
246 {"verify-pin1", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
247 {"verify-pin2", 1, 1, 0, cmd_verify_chv}, |
122
c0cd0d4635bb
fc-simtool verify-sjs1-adm1 command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
248 {"verify-sjs1-adm1", 1, 1, 0, cmd_verify_sjs1_adm1}, |
210
9797417ececa
fc-simtool write-acc command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
209
diff
changeset
|
249 {"write-acc", 1, 1, 0, cmd_write_acc}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
250 {"write-iccid", 1, 1, 0, cmd_write_iccid}, |
182
f4edccd4b583
fc-simtool: write-iccid-sh{18,19} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
172
diff
changeset
|
251 {"write-iccid-sh18", 1, 1, 0, cmd_write_iccid_sh18}, |
f4edccd4b583
fc-simtool: write-iccid-sh{18,19} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
172
diff
changeset
|
252 {"write-iccid-sh19", 1, 1, 0, cmd_write_iccid_sh19}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
253 {"write-imsi", 1, 1, 0, cmd_write_imsi}, |
183
2545dd27ca38
fc-simtool write-imsi-sh command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
182
diff
changeset
|
254 {"write-imsi-sh", 1, 1, 0, cmd_write_imsi_sh}, |
211
31cd62f91522
fc-simtool write-spn command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
210
diff
changeset
|
255 {"write-spn", 2, 2, 0, cmd_write_spn}, |
209
eb16c8841486
fc-simtool write-sst command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
256 {"write-sst", 1, 1, 0, cmd_write_sst}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
257 {0, 0, 0, 0, 0} |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 }; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
260 static FILE * |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
261 handle_output_redir(str) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
262 char *str; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
263 { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
264 char *cp, *fn; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
265 FILE *outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
266 |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
267 for (cp = str; isspace(*cp); cp++) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
268 ; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
269 if (!*cp || *cp == '#') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
270 fprintf(stderr, "error: no filename after '>'\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
271 return(0); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
272 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
273 for (fn = cp; *cp && !isspace(*cp); cp++) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
274 ; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
275 if (*cp) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
276 *cp++ = '\0'; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
277 while (isspace(*cp)) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
278 cp++; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
279 if (*cp && *cp != '#') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
280 fprintf(stderr, "error: invalid syntax after '>'\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
281 return(0); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
282 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
283 outf = fopen(fn, "w"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
284 if (!outf) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
285 perror(fn); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
286 return outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
287 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
288 |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 simtool_dispatch_cmd(cmd, is_script) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 char *cmd; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 { |
147
dcbabc398c6a
increase max number of skip-ID arguments for bfsearch
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
292 char *argv[20]; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 char *cp, **ap; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 struct cmdtab *tp; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
295 FILE *outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
296 int rc; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 for (cp = cmd; isspace(*cp); cp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 ; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 if (!*cp || *cp == '#') |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 return(0); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 if (is_script) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 printf("Script command: %s\n", cp); |
131
7305f2e63d66
fc-simtool: '!' escape in command dispatch
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
304 if (*cp == '!') |
7305f2e63d66
fc-simtool: '!' escape in command dispatch
Mychaela Falconia <falcon@freecalypso.org>
parents:
126
diff
changeset
|
305 return system(cp + 1); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 argv[0] = cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 while (*cp && !isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 if (*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 for (tp = cmdtab; tp->cmd; tp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 if (!strcmp(tp->cmd, argv[0])) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 if (!tp->func) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 fprintf(stderr, "error: no such command\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 for (ap = argv + 1; ; ) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 while (isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 cp++; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
321 if (!*cp || *cp == '#' || *cp == '>') |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 if (ap - argv - 1 >= tp->maxargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 fprintf(stderr, "error: too many arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 if (*cp == '"') { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 *ap++ = ++cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 for (;;) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 if (!*cp) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 unterm_qstring: fprintf(stderr, |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 "error: unterminated quoted string\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 if (*cp == '"') |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 if (*cp++ == '\\') { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 if (!*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 goto unterm_qstring; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 } else { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 *ap++ = cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 while (*cp && !isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 if (*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 if (ap - argv - 1 < tp->minargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 fprintf(stderr, "error: too few arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 *ap = 0; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
357 if (*cp == '>') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
358 if (!tp->allow_redir) { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
359 fprintf(stderr, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
360 "error: command does not support output redirection\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
361 return(-1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
362 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
363 outf = handle_output_redir(cp + 1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
364 if (!outf) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
365 return(-1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
366 } else |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
367 outf = stdout; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
368 rc = tp->func(ap - argv, argv, outf); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
369 if (outf != stdout) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
370 fclose(outf); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
371 return rc; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 dispatch_ready_argv(argc, argv) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 char **argv; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 struct cmdtab *tp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 for (tp = cmdtab; tp->cmd; tp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 if (!strcmp(tp->cmd, argv[0])) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 if (!tp->func) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 fprintf(stderr, "error: no such command\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 if (argc - 1 > tp->maxargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 fprintf(stderr, "error: too many arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 if (argc - 1 < tp->minargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 fprintf(stderr, "error: too few arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 } |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
394 return tp->func(argc, argv, stdout); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 } |