changeset 2:11f4f8a8fa33

pcsc: ATR code refactoring
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 01:22:37 +0000
parents f7a03e53bb2c
children 45ea06eaa9fd
files pcsc/atrfunc.c pcsc/atrmain.c
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pcsc/atrfunc.c	Sun Mar 14 01:09:23 2021 +0000
+++ b/pcsc/atrfunc.c	Sun Mar 14 01:22:37 2021 +0000
@@ -10,7 +10,8 @@
 
 #define	MAX_ATR_BYTES	33
 
-retrieve_atr(decor)
+retrieve_atr(head)
+	char *head;
 {
 	u_char atrbuf[MAX_ATR_BYTES];
 	LONG rv;
@@ -25,12 +26,9 @@
 		SCardReleaseContext(hContext);
 		exit(1);
 	}
-	if (decor)
-		printf("ATR:");
+	fputs(head, stdout);
 	for (n = 0; n < dwAttrLen; n++) {
-		if (decor)
-			putchar(' ');
-		printf("%02X", atrbuf[n]);
+		printf(" %02X", atrbuf[n]);
 	}
 	putchar('\n');
 	return(0);
--- a/pcsc/atrmain.c	Sun Mar 14 01:09:23 2021 +0000
+++ b/pcsc/atrmain.c	Sun Mar 14 01:22:37 2021 +0000
@@ -16,7 +16,7 @@
 	select_reader_by_num();
 	printf("Card reader name: %s\n", selected_reader);
 	connect_to_card();
-	retrieve_atr(1);
+	retrieve_atr("ATR:");
 	SCardDisconnect(hCard, SCARD_UNPOWER_CARD);
 	SCardReleaseContext(hContext);
 	exit(0);