changeset 5:ce189c97b7b1

check_simresp_all_blank() factored out into libcommon
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 11 Feb 2021 23:31:51 +0000
parents 744fabd6bd3f
children 2c72709e0891
files libcommon/Makefile libcommon/chkblank.c simtool/dumpdir.c simtool/pbdump.c
diffstat 4 files changed, 19 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/Makefile	Thu Feb 11 23:13:27 2021 +0000
+++ b/libcommon/Makefile	Thu Feb 11 23:31:51 2021 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2 -I/usr/include/PCSC
-OBJS=	alpha_decode.o alpha_valid.o apdu.o atr.o cardconnect.o exit.o \
-	hexdump.o hexread.o hexstr.o names.o pinentry.o
+OBJS=	alpha_decode.o alpha_valid.o apdu.o atr.o cardconnect.o chkblank.o \
+	exit.o hexdump.o hexread.o hexstr.o names.o pinentry.o
 LIB=	libcommon.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcommon/chkblank.c	Thu Feb 11 23:31:51 2021 +0000
@@ -0,0 +1,14 @@
+#include <sys/types.h>
+#include "simresp.h"
+
+check_simresp_all_blank()
+{
+	u_char *dp, *endp;
+
+	dp = sim_resp_data;
+	endp = sim_resp_data + sim_resp_data_len;
+	while (dp < endp)
+		if (*dp++ != 0xFF)
+			return(0);
+	return(1);
+}
--- a/simtool/dumpdir.c	Thu Feb 11 23:13:27 2021 +0000
+++ b/simtool/dumpdir.c	Thu Feb 11 23:31:51 2021 +0000
@@ -9,19 +9,6 @@
 #include "curfile.h"
 #include "file_id.h"
 
-static
-check_all_blank()
-{
-	u_char *dp, *endp;
-
-	dp = sim_resp_data;
-	endp = sim_resp_data + sim_resp_data_len;
-	while (dp < endp)
-		if (*dp++ != 0xFF)
-			return(0);
-	return(1);
-}
-
 static void
 dump_aid(tlv)
 	u_char *tlv;
@@ -144,7 +131,7 @@
 		rc = readrec_op(recno, 0x04, curfile_record_len);
 		if (rc < 0)
 			return(rc);
-		if (check_all_blank())
+		if (check_simresp_all_blank())
 			continue;
 		dump_record(recno);
 	}
--- a/simtool/pbdump.c	Thu Feb 11 23:13:27 2021 +0000
+++ b/simtool/pbdump.c	Thu Feb 11 23:31:51 2021 +0000
@@ -14,19 +14,6 @@
 	{'0','1','2','3','4','5','6','7','8','9','*','#','a','b','c','?'};
 
 static
-check_all_blank()
-{
-	u_char *dp, *endp;
-
-	dp = sim_resp_data;
-	endp = sim_resp_data + sim_resp_data_len;
-	while (dp < endp)
-		if (*dp++ != 0xFF)
-			return(0);
-	return(1);
-}
-
-static
 decode_number(data, nbytes, out)
 	u_char *data;
 	unsigned nbytes;
@@ -131,7 +118,7 @@
 				fclose(outf);
 			return(rc);
 		}
-		if (check_all_blank())
+		if (check_simresp_all_blank())
 			continue;
 		dump_record(recno, outf);
 	}
@@ -173,7 +160,7 @@
 		rc = readrec_op(recno, 0x04, curfile_record_len);
 		if (rc < 0)
 			return(rc);
-		if (check_all_blank())
+		if (check_simresp_all_blank())
 			continue;
 		dump_record(recno, stdout);
 	}