changeset 33:8a4f3d00d997

more refactoring of (select reader by number) logic
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Feb 2021 17:28:05 +0000
parents b37fcb235848
children 91bcf84a5323
files libcommon/cardconnect.c libcommon/cardif.h misc/fc-pcsc-atr.c simtool/main.c uicc/main.c
diffstat 5 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/cardconnect.c	Fri Feb 12 17:22:25 2021 +0000
+++ b/libcommon/cardconnect.c	Fri Feb 12 17:28:05 2021 +0000
@@ -8,6 +8,7 @@
 SCARDCONTEXT hContext;
 SCARDHANDLE hCard;
 char *reader_list, *selected_reader;
+unsigned select_reader_num;
 
 setup_pcsc_context()
 {
@@ -57,14 +58,13 @@
 	return(0);
 }
 
-select_reader_num(select_num)
-	unsigned select_num;
+select_reader_by_num()
 {
 	char *cp;
 	unsigned num;
 
 	for (cp = reader_list, num = 0; *cp; num++) {
-		if (num == select_num) {
+		if (num == select_reader_num) {
 			selected_reader = cp;
 			return(0);
 		}
@@ -72,7 +72,7 @@
 	}
 	fprintf(stderr,
 		"error: requested reader #%u, but only %u readers found\n",
-		select_num, num);
+		select_reader_num, num);
 	SCardReleaseContext(hContext);
 	exit(1);
 }
--- a/libcommon/cardif.h	Fri Feb 12 17:22:25 2021 +0000
+++ b/libcommon/cardif.h	Fri Feb 12 17:28:05 2021 +0000
@@ -3,3 +3,4 @@
 extern SCARDCONTEXT hContext;
 extern SCARDHANDLE hCard;
 extern char *reader_list, *selected_reader;
+extern unsigned select_reader_num;
--- a/misc/fc-pcsc-atr.c	Fri Feb 12 17:22:25 2021 +0000
+++ b/misc/fc-pcsc-atr.c	Fri Feb 12 17:28:05 2021 +0000
@@ -11,7 +11,7 @@
 
 	setup_pcsc_context();
 	get_reader_list();
-	select_reader_num(0);
+	select_reader_by_num();
 	printf("Card reader name: %s\n", selected_reader);
 	connect_to_card();
 	rc = retrieve_atr();
--- a/simtool/main.c	Fri Feb 12 17:22:25 2021 +0000
+++ b/simtool/main.c	Fri Feb 12 17:28:05 2021 +0000
@@ -13,7 +13,7 @@
 
 	setup_pcsc_context();
 	get_reader_list();
-	select_reader_num(0);
+	select_reader_by_num();
 	if (argc < 2)
 		printf("Card reader name: %s\n", selected_reader);
 	connect_to_card();
--- a/uicc/main.c	Fri Feb 12 17:22:25 2021 +0000
+++ b/uicc/main.c	Fri Feb 12 17:28:05 2021 +0000
@@ -13,7 +13,7 @@
 
 	setup_pcsc_context();
 	get_reader_list();
-	select_reader_num(0);
+	select_reader_by_num();
 	if (argc < 2)
 		printf("Card reader name: %s\n", selected_reader);
 	connect_to_card();