diff simtool/main.c @ 124:6c4567dd8946

fc-simtool: add non-interactive one-shot command (or script) mode
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Jan 2021 18:56:34 +0000
parents b391204d3cd5
children
line wrap: on
line diff
--- a/simtool/main.c	Thu Jan 28 18:42:24 2021 +0000
+++ b/simtool/main.c	Thu Jan 28 18:56:34 2021 +0000
@@ -9,19 +9,27 @@
 	char **argv;
 {
 	char command[512];
+	int rc;
 
 	setup_pcsc_context();
 	get_reader_name();
 	printf("Card reader name: %s\n", reader_name_buf);
 	connect_to_card();
 	retrieve_atr();
+	if (argc >= 2) {
+		rc = dispatch_ready_argv(argc - 1, argv + 1);
+		if (rc)
+			error_exit();
+		else
+			good_exit();
+	}
 	for (;;) {
 		if (isatty(0)) {
 			fputs("simtool> ", stdout);
 			fflush(stdout);
 		}
 		if (!fgets(command, sizeof command, stdin))
-			cmd_exit();
+			good_exit();
 		simtool_dispatch_cmd(command, 0);
 	}
 }