changeset 34:91bcf84a5323

-p reader selection implemented in fc-pcsc-atr
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Feb 2021 17:39:18 +0000
parents 8a4f3d00d997
children 360d07419357
files libcommon/Makefile libcommon/globalopts.c misc/fc-pcsc-atr.c
diffstat 3 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/Makefile	Fri Feb 12 17:28:05 2021 +0000
+++ b/libcommon/Makefile	Fri Feb 12 17:39:18 2021 +0000
@@ -1,9 +1,9 @@
 CC=	gcc
 CFLAGS=	-O2 -I/usr/include/PCSC
 OBJS=	alpha_decode.o alpha_fromfile.o alpha_valid.o apdu.o atr.o \
-	cardconnect.o chkblank.o dumpdirfunc.o exit.o gsm7_decode.o \
-	gsm7_encode.o gsm7_encode_table.o hexdump.o hexread.o hexstr.o names.o \
-	number_decode.o number_encode.o pinentry.o revnibbles.o
+	cardconnect.o chkblank.o dumpdirfunc.o exit.o globalopts.o \
+	gsm7_decode.o gsm7_encode.o gsm7_encode_table.o hexdump.o hexread.o \
+	hexstr.o names.o number_decode.o number_encode.o pinentry.o revnibbles.o
 LIB=	libcommon.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcommon/globalopts.c	Fri Feb 12 17:39:18 2021 +0000
@@ -0,0 +1,29 @@
+/*
+ * This module implements parsing of global command line options.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern unsigned select_reader_num;
+
+parse_global_options(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	int c;
+
+	while ((c = getopt(argc, argv, "+p:")) != EOF) {
+		switch (c) {
+		case 'p':
+			select_reader_num = atoi(optarg);
+			continue;
+		case '?':
+		default:
+			/* error msg already printed */
+			exit(1);
+		}
+	}
+	return(0);
+}
--- a/misc/fc-pcsc-atr.c	Fri Feb 12 17:28:05 2021 +0000
+++ b/misc/fc-pcsc-atr.c	Fri Feb 12 17:39:18 2021 +0000
@@ -9,6 +9,7 @@
 {
 	int rc;
 
+	parse_global_options(argc, argv);
 	setup_pcsc_context();
 	get_reader_list();
 	select_reader_by_num();