FreeCalypso > hg > fc-pcsc-tools
annotate simtool/dispatch.c @ 122:c0cd0d4635bb
fc-simtool verify-sjs1-adm1 command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 Feb 2021 01:20:50 +0000 |
parents | 8e70ee7c194f |
children | d0d1c0b35831 |
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(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern int cmd_change_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern int cmd_disable_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern int cmd_enable_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern int cmd_exec(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern int cmd_fix_sysmo_msisdn(); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
18 extern int cmd_fplmn_dump(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
19 extern int cmd_fplmn_erase(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
20 extern int cmd_fplmn_erase_all(); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
21 extern int cmd_fplmn_write(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern int cmd_grcard1_set_adm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extern int cmd_grcard1_set_ki(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 extern int cmd_grcard1_set_pin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 extern int cmd_grcard2_set_adm(); |
74
8562d8508cf2
grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
26 extern int cmd_grcard2_set_adm_hex(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 extern int cmd_grcard2_set_pin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 extern int cmd_grcard2_set_puk(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 extern int cmd_grcard2_set_super(); |
74
8562d8508cf2
grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
68
diff
changeset
|
30 extern int cmd_grcard2_set_super_hex(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 extern int cmd_iccid(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 extern int cmd_imsi(); |
76
0b29c0d19db4
fc-simtool: dump-lnd command renamed to lnd-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
74
diff
changeset
|
33 extern int cmd_lnd_dump(); |
84
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
34 extern int cmd_lnd_erase(); |
88
ae831b21ef77
lnd-restore command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
87
diff
changeset
|
35 extern int cmd_lnd_restore(); |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
82
diff
changeset
|
36 extern int cmd_lnd_write(); |
54
2d1679c7975b
fc-simtool opl-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
37 extern int cmd_opl_dump(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 extern int cmd_pb_dump(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 extern int cmd_pb_dump_rec(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 extern int cmd_pb_erase(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 extern int cmd_pb_erase_one(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 extern int cmd_pb_erase_range(); |
87
bc862d41f96b
pb-restore command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
84
diff
changeset
|
43 extern int cmd_pb_restore(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 extern int cmd_pb_update(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 extern int cmd_pb_update_imm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 extern int cmd_pb_update_imm_hex(); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
47 extern int cmd_plmnsel_dump(); |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
48 extern int cmd_plmnsel_erase(); |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
49 extern int cmd_plmnsel_erase_all(); |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
88
diff
changeset
|
50 extern int cmd_plmnsel_write(); |
50
dc8a2e6fa03e
fc-simtool pnn-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
51 extern int cmd_pnn_dump(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 extern int cmd_readbin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 extern int cmd_readef(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 extern int cmd_readrec(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 extern int cmd_restore_file(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 extern int cmd_savebin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 extern int cmd_save_sms_bin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 extern int cmd_select(); |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
59 extern int cmd_sim_resp(); |
42
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
60 extern int cmd_sms_erase_all(); |
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
61 extern int cmd_sms_erase_one(); |
2714d379edc2
fc-simtool sms-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
40
diff
changeset
|
62 extern int cmd_sms_erase_range(); |
38
f5a26c1d0b93
fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
29
diff
changeset
|
63 extern int cmd_smsp_dump(); |
40
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
64 extern int cmd_smsp_erase_all(); |
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
65 extern int cmd_smsp_erase_one(); |
4c240a37e7c4
fc-simtool smsp-erase-* command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
39
diff
changeset
|
66 extern int cmd_smsp_erase_range(); |
39
2467b7acad1f
fc-simtool smsp-restore implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
38
diff
changeset
|
67 extern int cmd_smsp_restore(); |
44
f4eb1e83b4b3
fc-simtool smsp-set command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
68 extern int cmd_smsp_set(); |
45
5bca197e7495
fc-simtool smsp-set-tag command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
69 extern int cmd_smsp_set_tag(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 extern int cmd_spn(); |
59
c56e63a8725d
fc-simtool sst-dump command shortened to just sst
Mychaela Falconia <falcon@freecalypso.org>
parents:
58
diff
changeset
|
71 extern int cmd_sst(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 extern int cmd_telecom_sum(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 extern int cmd_uicc_dir(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 extern int cmd_unblock_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 extern int cmd_update_bin(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 extern int cmd_update_bin_imm(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 extern int cmd_update_rec(); |
78
702c2c40e51a
fc-simtool update-rec-prev command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
76
diff
changeset
|
78 extern int cmd_update_rec_prev(); |
61
633033af6fb8
fc-simtool user-sum command implemented,
Mychaela Falconia <falcon@freecalypso.org>
parents:
59
diff
changeset
|
79 extern int cmd_user_sum(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 extern int cmd_verify_chv(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 extern int cmd_verify_ext(); |
47
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
45
diff
changeset
|
82 extern int cmd_verify_hex(); |
122
c0cd0d4635bb
fc-simtool verify-sjs1-adm1 command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
83 extern int cmd_verify_sjs1_adm1(); |
68
105aa3d1a494
fc-simtool write-iccid command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
67
diff
changeset
|
84 extern int cmd_write_iccid(); |
67
9ff7ee99346f
forgot to hook in newly added write-imsi command
Mychaela Falconia <falcon@freecalypso.org>
parents:
63
diff
changeset
|
85 extern int cmd_write_imsi(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 extern int good_exit(); |
29
d368051576d0
fc-simtool & fc-uicc-tool: add explicit atr command
Mychaela Falconia <falcon@freecalypso.org>
parents:
1
diff
changeset
|
88 extern int retrieve_atr(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 static struct cmdtab { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 char *cmd; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 int minargs; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 int maxargs; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
94 int allow_redir; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 int (*func)(); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } cmdtab[] = { |
108
e17940d7ce35
fc-simtool a38: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
107
diff
changeset
|
97 {"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
|
98 {"apdu", 1, 1, 0, cmd_apdu}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
99 {"atr", 0, 0, 0, retrieve_atr}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
100 {"change-chv1", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
101 {"change-chv2", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
102 {"change-pin1", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
103 {"change-pin2", 2, 2, 0, cmd_change_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
104 {"disable-chv", 1, 1, 0, cmd_disable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
105 {"disable-chv1", 1, 1, 0, cmd_disable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
106 {"disable-pin", 1, 1, 0, cmd_disable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
107 {"disable-pin1", 1, 1, 0, cmd_disable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
108 {"enable-chv", 1, 1, 0, cmd_enable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
109 {"enable-chv1", 1, 1, 0, cmd_enable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
110 {"enable-pin", 1, 1, 0, cmd_enable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
111 {"enable-pin1", 1, 1, 0, cmd_enable_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
112 {"exec", 1, 1, 0, cmd_exec}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
113 {"exit", 0, 0, 0, good_exit}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
114 {"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
|
115 {"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
|
116 {"fplmn-erase", 1, 2, 0, cmd_fplmn_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
117 {"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
|
118 {"fplmn-write", 2, 2, 0, cmd_fplmn_write}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
119 {"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
|
120 {"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
|
121 {"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
|
122 {"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
|
123 {"grcard1-set-pin2", 2, 2, 0, cmd_grcard1_set_pin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
124 {"grcard2-set-adm", 1, 1, 0, cmd_grcard2_set_adm}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
125 {"grcard2-set-adm-hex", 1, 1, 0, cmd_grcard2_set_adm_hex}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
126 {"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
|
127 {"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
|
128 {"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
|
129 {"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
|
130 {"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
|
131 {"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
|
132 {"iccid", 0, 0, 1, cmd_iccid}, |
2aa92dfcb4b5
fc-simtool iccid, imsi, spn: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
133 {"imsi", 0, 0, 1, cmd_imsi}, |
111
869488ef86b6
pb-dump command family reworked for new output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
134 {"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
|
135 {"lnd-erase", 0, 0, 0, cmd_lnd_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
136 {"lnd-restore", 1, 1, 0, cmd_lnd_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
137 {"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
|
138 {"opl-dump", 0, 0, 1, cmd_opl_dump}, |
111
869488ef86b6
pb-dump command family reworked for new output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
139 {"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
|
140 {"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
|
141 {"pb-erase", 1, 1, 0, cmd_pb_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
142 {"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
|
143 {"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
|
144 {"pb-restore", 2, 2, 0, cmd_pb_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
145 {"pb-update", 2, 2, 0, cmd_pb_update}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
146 {"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
|
147 {"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
|
148 {"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
|
149 {"plmnsel-erase", 1, 2, 0, cmd_plmnsel_erase}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
150 {"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
|
151 {"plmnsel-write", 2, 2, 0, cmd_plmnsel_write}, |
114
2c07684a3980
fc-simtool pnn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
113
diff
changeset
|
152 {"pnn-dump", 0, 0, 1, cmd_pnn_dump}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
153 {"quit", 0, 0, 0, good_exit}, |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
154 {"readbin", 2, 2, 1, cmd_readbin}, |
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
155 {"readef", 1, 1, 1, cmd_readef}, |
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
156 {"readrec", 1, 2, 1, cmd_readrec}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
157 {"restore-file", 2, 2, 0, cmd_restore_file}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
158 {"savebin", 2, 2, 0, cmd_savebin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
159 {"save-sms-bin", 1, 1, 0, cmd_save_sms_bin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
160 {"select", 1, 1, 0, cmd_select}, |
107
f1836c8d36cb
hexdump output commands reworked to support redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
106
diff
changeset
|
161 {"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
|
162 {"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
|
163 {"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
|
164 {"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
|
165 {"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
|
166 {"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
|
167 {"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
|
168 {"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
|
169 {"smsp-restore", 1, 1, 0, cmd_smsp_restore}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
170 {"smsp-set", 2, 6, 0, cmd_smsp_set}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
171 {"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
|
172 {"spn", 0, 0, 1, cmd_spn}, |
116
9c16cf1a79af
fc-simtool sst: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
173 {"sst", 0, 0, 1, cmd_sst}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
174 {"telecom-sum", 0, 0, 0, cmd_telecom_sum}, |
106
dcfec53643c5
EF_DIR dump commands support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
104
diff
changeset
|
175 {"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
|
176 {"unblock-chv1", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
177 {"unblock-chv2", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
178 {"unblock-pin1", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
179 {"unblock-pin2", 2, 2, 0, cmd_unblock_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
180 {"update-bin", 2, 2, 0, cmd_update_bin}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
181 {"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
|
182 {"update-rec", 2, 2, 0, cmd_update_rec}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
183 {"update-rec-prev", 1, 1, 0, cmd_update_rec_prev}, |
117
b89bc690dec4
fc-simtool user-sum: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
184 {"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
|
185 {"verify-chv1", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
186 {"verify-chv2", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
187 {"verify-ext", 2, 2, 0, cmd_verify_ext}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
188 {"verify-hex", 2, 2, 0, cmd_verify_hex}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
189 {"verify-pin1", 1, 1, 0, cmd_verify_chv}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
190 {"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
|
191 {"verify-sjs1-adm1", 1, 1, 0, cmd_verify_sjs1_adm1}, |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
192 {"write-iccid", 1, 1, 0, cmd_write_iccid}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
193 {"write-imsi", 1, 1, 0, cmd_write_imsi}, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
194 {0, 0, 0, 0, 0} |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 }; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
197 static FILE * |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
198 handle_output_redir(str) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
199 char *str; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
200 { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
201 char *cp, *fn; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
202 FILE *outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
203 |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
204 for (cp = str; isspace(*cp); cp++) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
205 ; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
206 if (!*cp || *cp == '#') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
207 fprintf(stderr, "error: no filename after '>'\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
208 return(0); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
209 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
210 for (fn = cp; *cp && !isspace(*cp); cp++) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
211 ; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
212 if (*cp) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
213 *cp++ = '\0'; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
214 while (isspace(*cp)) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
215 cp++; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
216 if (*cp && *cp != '#') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
217 fprintf(stderr, "error: invalid syntax after '>'\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
218 return(0); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
219 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
220 outf = fopen(fn, "w"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
221 if (!outf) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
222 perror(fn); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
223 return outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
224 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
225 |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 simtool_dispatch_cmd(cmd, is_script) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 char *cmd; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 char *argv[10]; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 char *cp, **ap; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 struct cmdtab *tp; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
232 FILE *outf; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
233 int rc; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 for (cp = cmd; isspace(*cp); cp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 ; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 if (!*cp || *cp == '#') |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 return(0); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 if (is_script) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 printf("Script command: %s\n", cp); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 argv[0] = cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 while (*cp && !isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 if (*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 for (tp = cmdtab; tp->cmd; tp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 if (!strcmp(tp->cmd, argv[0])) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 if (!tp->func) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 fprintf(stderr, "error: no such command\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 for (ap = argv + 1; ; ) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 while (isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 cp++; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
256 if (!*cp || *cp == '#' || *cp == '>') |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 if (ap - argv - 1 >= tp->maxargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 fprintf(stderr, "error: too many arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 if (*cp == '"') { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 *ap++ = ++cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 for (;;) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 if (!*cp) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 unterm_qstring: fprintf(stderr, |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 "error: unterminated quoted string\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 if (*cp == '"') |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 if (*cp++ == '\\') { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 if (!*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 goto unterm_qstring; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 } else { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 *ap++ = cp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 while (*cp && !isspace(*cp)) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 cp++; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 if (*cp) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 *cp++ = '\0'; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 if (ap - argv - 1 < tp->minargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 fprintf(stderr, "error: too few arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 *ap = 0; |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
292 if (*cp == '>') { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
293 if (!tp->allow_redir) { |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
294 fprintf(stderr, |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
295 "error: command does not support output redirection\n"); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
296 return(-1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
297 } |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
298 outf = handle_output_redir(cp + 1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
299 if (!outf) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
300 return(-1); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
301 } else |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
302 outf = stdout; |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
303 rc = tp->func(ap - argv, argv, outf); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
304 if (outf != stdout) |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
305 fclose(outf); |
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
306 return rc; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 dispatch_ready_argv(argc, argv) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 char **argv; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 struct cmdtab *tp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 for (tp = cmdtab; tp->cmd; tp++) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 if (!strcmp(tp->cmd, argv[0])) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 break; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 if (!tp->func) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 fprintf(stderr, "error: no such command\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 if (argc - 1 > tp->maxargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 fprintf(stderr, "error: too many arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 if (argc - 1 < tp->minargs) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 fprintf(stderr, "error: too few arguments\n"); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 } |
104
4709cff90a58
fc-simtool: infrastructure for output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
329 return tp->func(argc, argv, stdout); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 } |