diff simtool/saverestore.c @ 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
line wrap: on
line diff
--- 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;