diff libcommon/globalopts.c @ 9:c9ef9e91dd8e

new libcommon, initial version
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 06:55:38 +0000
parents
children 9eb5460f51a6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcommon/globalopts.c	Sun Mar 14 06:55:38 2021 +0000
@@ -0,0 +1,32 @@
+/*
+ * This module implements parsing of global command line options.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+unsigned calypso_fd, pcsc_reader_num;
+
+parse_global_options(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	int c;
+
+	while ((c = getopt(argc, argv, "+C:p:")) != EOF) {
+		switch (c) {
+		case 'C':
+			calypso_fd = atoi(optarg);
+			continue;
+		case 'p':
+			pcsc_reader_num = atoi(optarg);
+			continue;
+		case '?':
+		default:
+			/* error msg already printed */
+			exit(1);
+		}
+	}
+	return(0);
+}