FreeCalypso > hg > freecalypso-hwlab
changeset 119:c77b0d4cf89f
fc-simtool: save-sms-bin command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 04:19:52 +0000 |
parents | b563ff1c1a2a |
children | 70219d92c32e |
files | simtool/dispatch.c simtool/saverestore.c |
diffstat | 2 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Thu Jan 28 04:11:28 2021 +0000 +++ b/simtool/dispatch.c Thu Jan 28 04:19:52 2021 +0000 @@ -28,6 +28,7 @@ extern int cmd_readrec(); extern int cmd_restore_file(); extern int cmd_savebin(); +extern int cmd_save_sms_bin(); extern int cmd_select(); extern int cmd_spn(); extern int cmd_telecom_sum(); @@ -75,6 +76,7 @@ {"readrec", 1, 2, cmd_readrec}, {"restore-file", 2, 2, cmd_restore_file}, {"savebin", 2, 2, cmd_savebin}, + {"save-sms-bin", 1, 1, cmd_save_sms_bin}, {"select", 1, 1, cmd_select}, {"sim-resp", 0, 0, display_sim_resp_in_hex}, {"spn", 0, 0, cmd_spn},
--- a/simtool/saverestore.c Thu Jan 28 04:11:28 2021 +0000 +++ b/simtool/saverestore.c Thu Jan 28 04:19:52 2021 +0000 @@ -12,6 +12,7 @@ #include <pcsclite.h> #include <winscard.h> #include "globals.h" +#include "file_id.h" static savebin_transparent(outf) @@ -90,6 +91,36 @@ return(rc); } +cmd_save_sms_bin(argc, argv) + char **argv; +{ + int rc; + FILE *of; + + rc = select_op(DF_TELECOM); + if (rc < 0) + return(rc); + rc = select_op(EF_SMS); + if (rc < 0) + return(rc); + rc = parse_ef_select_response(); + if (rc < 0) + return(rc); + if (curfile_structure != 0x01 || curfile_record_len != 176) { + fprintf(stderr, + "error: EF_SMS is not linear fixed with 176-byte records\n"); + return(-1); + } + of = fopen(argv[1], "w"); + if (!of) { + perror(argv[1]); + return(-1); + } + rc = savebin_records(of); + fclose(of); + return(rc); +} + static restore_transparent(data) u_char *data;