changeset 117:b89bc690dec4

fc-simtool user-sum: support output redirection
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 07:39:26 +0000
parents 9c16cf1a79af
children 5d45cde6e4b2
files simtool/dispatch.c simtool/usersum.c
diffstat 2 files changed, 26 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Fri Feb 19 07:30:17 2021 +0000
+++ b/simtool/dispatch.c	Fri Feb 19 07:39:26 2021 +0000
@@ -178,7 +178,7 @@
 	{"update-bin-imm", 2, 2, 0, cmd_update_bin_imm},
 	{"update-rec", 2, 2, 0, cmd_update_rec},
 	{"update-rec-prev", 1, 1, 0, cmd_update_rec_prev},
-	{"user-sum", 0, 0, 0, cmd_user_sum},
+	{"user-sum", 0, 0, 1, cmd_user_sum},
 	{"verify-chv1", 1, 1, 0, cmd_verify_chv},
 	{"verify-chv2", 1, 1, 0, cmd_verify_chv},
 	{"verify-ext", 2, 2, 0, cmd_verify_ext},
--- a/simtool/usersum.c	Fri Feb 19 07:30:17 2021 +0000
+++ b/simtool/usersum.c	Fri Feb 19 07:39:26 2021 +0000
@@ -51,9 +51,10 @@
 }
 
 static
-do_phonebook_file(file_id, ef_name, book_name)
+do_phonebook_file(file_id, ef_name, book_name, outf)
 	unsigned file_id;
 	char *ef_name, *book_name;
+	FILE *outf;
 {
 	int rc;
 
@@ -74,13 +75,14 @@
 			ef_name, curfile_record_len);
 		return(-1);
 	}
-	printf("%s: %u entries, %u bytes of alpha tag\n", book_name,
+	fprintf(outf, "%s: %u entries, %u bytes of alpha tag\n", book_name,
 		curfile_record_count, curfile_record_len - 14);
 	return(0);
 }
 
 static
-do_sms_store()
+do_sms_store(outf)
+	FILE *outf;
 {
 	int rc;
 
@@ -95,12 +97,13 @@
 		"error: EF_SMS is not linear fixed with 176-byte records\n");
 		return(-1);
 	}
-	printf("SMS store: %u entries\n", curfile_record_count);
+	fprintf(outf, "SMS store: %u entries\n", curfile_record_count);
 	return(0);
 }
 
 static
-do_smsp_store()
+do_smsp_store(outf)
+	FILE *outf;
 {
 	int rc;
 
@@ -120,12 +123,15 @@
 			curfile_record_len);
 		return(-1);
 	}
-	printf("SMS parameter store: %u entries, %u bytes of alpha tag\n",
+	fprintf(outf,
+		"SMS parameter store: %u entries, %u bytes of alpha tag\n",
 		curfile_record_count, curfile_record_len - 28);
 	return(0);
 }
 
-cmd_user_sum()
+cmd_user_sum(argc, argv, outf)
+	char **argv;
+	FILE *outf;
 {
 	int rc;
 	u_char sst[SST_BYTES_USED];
@@ -137,45 +143,47 @@
 	if (rc < 0)
 		return(rc);
 	if ((sst[0] & 0x0C) == 0x0C) {
-		rc = do_phonebook_file(EF_ADN, "EF_ADN", "ADN phonebook");
+		rc = do_phonebook_file(EF_ADN, "EF_ADN", "ADN phonebook", outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[0] & 0x30) == 0x30) {
-		rc = do_phonebook_file(EF_FDN, "EF_FDN", "FDN phonebook");
+		rc = do_phonebook_file(EF_FDN, "EF_FDN", "FDN phonebook", outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[0] & 0xC0) == 0xC0) {
-		rc = do_sms_store();
+		rc = do_sms_store(outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[1] & 0x03) == 0x03)
-		printf("AoC service present\n");
+		fprintf(outf, "AoC service present\n");
 	if ((sst[2] & 0x03) == 0x03) {
-		rc = do_phonebook_file(EF_MSISDN, "EF_MSISDN", "MSISDN record");
+		rc = do_phonebook_file(EF_MSISDN, "EF_MSISDN", "MSISDN record",
+					outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[2] & 0xC0) == 0xC0) {
-		rc = do_smsp_store();
+		rc = do_smsp_store(outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[3] & 0x03) == 0x03) {
-		rc = do_phonebook_file(EF_LND, "EF_LND", "LND cyclic store");
+		rc = do_phonebook_file(EF_LND, "EF_LND", "LND cyclic store",
+					outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[4] & 0x0C) == 0x0C) {
-		rc = do_phonebook_file(EF_SDN, "EF_SDN", "SDN phonebook");
+		rc = do_phonebook_file(EF_SDN, "EF_SDN", "SDN phonebook", outf);
 		if (rc < 0)
 			return(rc);
 	}
 	if ((sst[13] & 0x03) == 0x03)
-		printf("MBDN present\n");
+		fprintf(outf, "MBDN present\n");
 	if ((sst[13] & 0x0C) == 0x0C)
-		printf("MWIS present\n");
+		fprintf(outf, "MWIS present\n");
 	return(0);
 }