FreeCalypso > hg > fc-sim-tools
comparison uicc/writecmd.c @ 86:de23872796cb
fc-uicc-tool: update-rec-imm and update-rec-fill ported over from fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 11 Apr 2021 03:19:22 +0000 |
parents | c179deb9bb39 |
children |
comparison
equal
deleted
inserted
replaced
85:c179deb9bb39 | 86:de23872796cb |
---|---|
74 fprintf(stderr, "error: hex data length != EF record length\n"); | 74 fprintf(stderr, "error: hex data length != EF record length\n"); |
75 return(-1); | 75 return(-1); |
76 } | 76 } |
77 return update_rec_op(recno, mode, data, last_sel_file_record_len); | 77 return update_rec_op(recno, mode, data, last_sel_file_record_len); |
78 } | 78 } |
79 | |
80 cmd_update_rec_imm(argc, argv) | |
81 char **argv; | |
82 { | |
83 unsigned recno, mode; | |
84 u_char data[255]; | |
85 int rc; | |
86 | |
87 if (!last_sel_file_record_len) { | |
88 fprintf(stderr, "error: no record-based file selected\n"); | |
89 return(-1); | |
90 } | |
91 if (!strcmp(argv[1], "prev")) { | |
92 recno = 0; | |
93 mode = 0x03; | |
94 } else { | |
95 recno = strtoul(argv[1], 0, 0); | |
96 if (recno < 1 || recno > 255) { | |
97 fprintf(stderr, | |
98 "error: record number argument is out of range\n"); | |
99 return(-1); | |
100 } | |
101 mode = 0x04; | |
102 } | |
103 rc = decode_hex_data_from_string(argv[2], data, 1, 255); | |
104 if (rc < 0) | |
105 return(rc); | |
106 if (rc != last_sel_file_record_len) { | |
107 fprintf(stderr, "error: hex data length != EF record length\n"); | |
108 return(-1); | |
109 } | |
110 return update_rec_op(recno, mode, data, last_sel_file_record_len); | |
111 } | |
112 | |
113 cmd_update_rec_fill(argc, argv) | |
114 char **argv; | |
115 { | |
116 unsigned recno, mode, fill_byte; | |
117 u_char data[255]; | |
118 | |
119 if (!last_sel_file_record_len) { | |
120 fprintf(stderr, "error: no record-based file selected\n"); | |
121 return(-1); | |
122 } | |
123 if (!strcmp(argv[1], "prev")) { | |
124 recno = 0; | |
125 mode = 0x03; | |
126 } else { | |
127 recno = strtoul(argv[1], 0, 0); | |
128 if (recno < 1 || recno > 255) { | |
129 fprintf(stderr, | |
130 "error: record number argument is out of range\n"); | |
131 return(-1); | |
132 } | |
133 mode = 0x04; | |
134 } | |
135 fill_byte = strtoul(argv[2], 0, 16); | |
136 if (fill_byte > 0xFF) { | |
137 fprintf(stderr, "error: invalid fill byte argument\n"); | |
138 return(-1); | |
139 } | |
140 memset(data, fill_byte, last_sel_file_record_len); | |
141 return update_rec_op(recno, mode, data, last_sel_file_record_len); | |
142 } |