view simtool/main.c @ 85:c179deb9bb39

uicc/writecmd.c: forgot to update #include header set
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Apr 2021 02:48:22 +0000
parents 3fe1954f5dec
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern char be_reader_name[];
extern char be_atr_string[];
extern char be_extra_info[];

main(argc, argv)
	char **argv;
{
	extern int optind;
	char command[512];
	int rc, batch_stdin;

	parse_global_options(argc, argv);
	launch_backend();
	collect_backend_init_strings();
	if (argc > optind) {
		rc = dispatch_ready_argv(argc - optind, argv + optind);
		if (rc)
			exit(1);
		else
			good_exit();
	}
	if (be_reader_name[0])
		printf("Card reader name: %s\n", be_reader_name);
	if (be_atr_string[0])
		printf("ATR: %s\n", be_atr_string);
	if (be_extra_info[0])
		puts(be_extra_info);
	batch_stdin = !isatty(0);
	for (;;) {
		if (!batch_stdin) {
			fputs("simtool> ", stdout);
			fflush(stdout);
		}
		if (!fgets(command, sizeof command, stdin))
			good_exit();
		if (batch_stdin)
			printf("Stdin command: %s", command);
		rc = simtool_dispatch_cmd(command, 0);
		if (batch_stdin && rc)
			exit(1);
	}
}