changeset 217:52c0da56e979

simtool code: select_ef_opl() factored out
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Mar 2021 18:18:29 +0000
parents cd66e13eccf3
children f376ba028311
files simtool/opldump.c
diffstat 1 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/opldump.c	Sun Mar 07 18:03:55 2021 +0000
+++ b/simtool/opldump.c	Sun Mar 07 18:18:29 2021 +0000
@@ -9,6 +9,31 @@
 #include "curfile.h"
 #include "file_id.h"
 
+select_ef_opl()
+{
+	int rc;
+
+	rc = select_op(DF_GSM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_OPL);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x01) {
+		fprintf(stderr, "error: EF_OPL is not linear fixed\n");
+		return(-1);
+	}
+	if (curfile_record_len < 8) {
+		fprintf(stderr,
+"error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
+		return(-1);
+	}
+	return(0);
+}
+
 static void
 dump_record(recno, outf)
 	unsigned recno;
@@ -29,24 +54,9 @@
 	int rc;
 	unsigned recno;
 
-	rc = select_op(DF_GSM);
-	if (rc < 0)
-		return(rc);
-	rc = select_op(EF_OPL);
-	if (rc < 0)
-		return(rc);
-	rc = parse_ef_select_response();
+	rc = select_ef_opl();
 	if (rc < 0)
 		return(rc);
-	if (curfile_structure != 0x01) {
-		fprintf(stderr, "error: EF_OPL is not linear fixed\n");
-		return(-1);
-	}
-	if (curfile_record_len < 8) {
-		fprintf(stderr,
-"error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
-		return(-1);
-	}
 	for (recno = 1; recno <= curfile_record_count; recno++) {
 		rc = readrec_op(recno, 0x04, curfile_record_len);
 		if (rc < 0)