comparison uicc/writecmd.c @ 22:1b1468869ccf

new trimmed fc-uicc-tool is here
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Feb 2021 04:34:53 +0000
parents
children a1aa8ee2da85
comparison
equal deleted inserted replaced
21:d4dc86195382 22:1b1468869ccf
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 extern unsigned last_sel_file_record_len;
6
7 cmd_update_bin(argc, argv)
8 char **argv;
9 {
10 unsigned offset, len;
11 u_char data[255];
12 int rc;
13
14 offset = strtoul(argv[1], 0, 0);
15 if (offset > 0x7FFF) {
16 fprintf(stderr, "error: offset argument is out of range\n");
17 return(-1);
18 }
19 rc = read_hex_data_file(argv[2], data);
20 if (rc < 0)
21 return(rc);
22 len = rc;
23 return update_bin_op(offset, data, len);
24 }
25
26 cmd_update_bin_imm(argc, argv)
27 char **argv;
28 {
29 unsigned offset, len;
30 u_char data[255];
31 int rc;
32
33 offset = strtoul(argv[1], 0, 0);
34 if (offset > 0x7FFF) {
35 fprintf(stderr, "error: offset argument is out of range\n");
36 return(-1);
37 }
38 rc = decode_hex_data_from_string(argv[2], data, 1, 255);
39 if (rc < 0)
40 return(rc);
41 len = rc;
42 return update_bin_op(offset, data, len);
43 }
44
45 cmd_update_rec(argc, argv)
46 char **argv;
47 {
48 unsigned recno;
49 u_char data[255];
50 int rc;
51
52 if (!last_sel_file_record_len) {
53 fprintf(stderr, "error: no record-based file selected\n");
54 return(-1);
55 }
56 recno = strtoul(argv[1], 0, 0);
57 if (recno < 1 || recno > 255) {
58 fprintf(stderr,
59 "error: record number argument is out of range\n");
60 return(-1);
61 }
62 rc = read_hex_data_file(argv[2], data);
63 if (rc < 0)
64 return(rc);
65 if (rc != last_sel_file_record_len) {
66 fprintf(stderr, "error: hex data length != EF record length\n");
67 return(-1);
68 }
69 return update_rec_op(recno, 0x04, data, last_sel_file_record_len);
70 }