changeset 81:e89004a245ce

EF_LND code refactoring in prep for adding more lnd-* commands
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 17 Feb 2021 05:53:22 +0000
parents 54cebab70c19
children fe660c7ea97f
files simtool/pbcommon.c simtool/pbdump.c
diffstat 2 files changed, 27 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/pbcommon.c	Wed Feb 17 05:31:53 2021 +0000
+++ b/simtool/pbcommon.c	Wed Feb 17 05:53:22 2021 +0000
@@ -72,3 +72,29 @@
 	}
 	return(0);
 }
+
+select_ef_lnd()
+{
+	int rc;
+
+	rc = select_op(DF_TELECOM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_LND);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x03) {
+		fprintf(stderr, "error: EF_LND is not cyclic\n");
+		return(-1);
+	}
+	if (curfile_record_len < 14) {
+		fprintf(stderr,
+	"error: EF_LND has record length of %u bytes, less than minimum 14\n",
+			curfile_record_len);
+		return(-1);
+	}
+	return(0);
+}
--- a/simtool/pbdump.c	Wed Feb 17 05:31:53 2021 +0000
+++ b/simtool/pbdump.c	Wed Feb 17 05:53:22 2021 +0000
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include "simresp.h"
 #include "curfile.h"
-#include "file_id.h"
 
 static
 check_blank_area(dp, endp)
@@ -138,25 +137,9 @@
 	int rc;
 	unsigned recno;
 
-	rc = select_op(DF_TELECOM);
-	if (rc < 0)
-		return(rc);
-	rc = select_op(EF_LND);
-	if (rc < 0)
-		return(rc);
-	rc = parse_ef_select_response();
+	rc = select_ef_lnd();
 	if (rc < 0)
 		return(rc);
-	if (curfile_structure != 0x03) {
-		fprintf(stderr, "error: EF_LND is not cyclic\n");
-		return(-1);
-	}
-	if (curfile_record_len < 14) {
-		fprintf(stderr,
-	"error: EF_LND has record length of %u bytes, less than minimum 14\n",
-			curfile_record_len);
-		return(-1);
-	}
 	for (recno = 1; recno <= curfile_record_count; recno++) {
 		rc = readrec_op(recno, 0x04, curfile_record_len);
 		if (rc < 0)