FreeCalypso > hg > fc-pcsc-tools
annotate simtool/lndwrite.c @ 179:efe944a5c4e3
doc/Brute-force-search: update for data directory rename
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 02 Mar 2021 05:20:19 +0000 |
parents | 51f26fd967e2 |
children |
rev | line source |
---|---|
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
2 * This module implements lnd-write and lnd-erase commands. |
1
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 <sys/types.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <string.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <strings.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.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 #include "curfile.h" |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
12 cmd_lnd_write(argc, argv) |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 char **argv; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 u_char record[255], *fixp; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
18 rc = select_ef_lnd(); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 return(rc); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 memset(record, 0xFF, curfile_record_len); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 fixp = record + curfile_record_len - 14; |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
23 rc = encode_phone_number_arg(argv[1], fixp, 0); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return(rc); |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
26 if (argv[2]) { |
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
27 rc = qstring_arg_to_gsm7(argv[2], record, |
10
a76ec3e7da09
simtool/pbupdate.c: a little refactoring from fc-uicc-tool
Mychaela Falconia <falcon@freecalypso.org>
parents:
1
diff
changeset
|
28 curfile_record_len - 14); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return(rc); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
83
07e395fddfe1
lnd-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
32 return update_rec_op(0, 0x03, record, curfile_record_len); |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
84
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
34 |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
35 cmd_lnd_erase(argc, argv) |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
36 char **argv; |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
37 { |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
38 int rc; |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
39 u_char record[255]; |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
40 unsigned count; |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
41 |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
42 rc = select_ef_lnd(); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
43 if (rc < 0) |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
44 return(rc); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
45 memset(record, 0xFF, curfile_record_len); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
46 for (count = 0; count < curfile_record_count; count++) { |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
47 rc = update_rec_op(0, 0x03, record, curfile_record_len); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
48 if (rc < 0) |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
49 return(rc); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
50 } |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
51 return(0); |
51f26fd967e2
lnd-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
52 } |