FreeCalypso > hg > fc-pcsc-tools
comparison simtool/plmnsel.c @ 99:d2e800abd257
fc-simtool plmnsel-write command implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 17 Feb 2021 22:43:18 +0000 |
| parents | 4eb447be01c0 |
| children | a75c0aafb367 |
comparison
equal
deleted
inserted
replaced
| 98:6ba14a9247d2 | 99:d2e800abd257 |
|---|---|
| 2 * This module implements commands for working with EF_PLMNsel. | 2 * This module implements commands for working with EF_PLMNsel. |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 #include <sys/types.h> | 5 #include <sys/types.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | |
| 7 #include "simresp.h" | 8 #include "simresp.h" |
| 8 #include "curfile.h" | 9 #include "curfile.h" |
| 9 #include "file_id.h" | 10 #include "file_id.h" |
| 10 | 11 |
| 11 static | 12 static |
| 86 } | 87 } |
| 87 if (linelen) | 88 if (linelen) |
| 88 putchar('\n'); | 89 putchar('\n'); |
| 89 return(0); | 90 return(0); |
| 90 } | 91 } |
| 92 | |
| 93 cmd_plmnsel_write(argc, argv) | |
| 94 char **argv; | |
| 95 { | |
| 96 int rc; | |
| 97 unsigned idx; | |
| 98 u_char rec[3]; | |
| 99 | |
| 100 rc = select_ef_plmnsel(); | |
| 101 if (rc < 0) | |
| 102 return(rc); | |
| 103 idx = strtoul(argv[1], 0, 0); | |
| 104 if (idx >= curfile_total_size / 3) { | |
| 105 fprintf(stderr, "error: specified index is out of range\n"); | |
| 106 return(-1); | |
| 107 } | |
| 108 rc = encode_plmn_3bytes(argv[2], rec); | |
| 109 if (rc < 0) | |
| 110 return(rc); | |
| 111 return update_bin_op(idx * 3, rec, 3); | |
| 112 } |
