view uicc/main.c @ 61:97646b363eaa

fc-uicc-tool: sws-lookup and sws-auth-* commands ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 Mar 2021 06:07:06 +0000
parents e2ef4b8e4136
children f6d5cff989d6
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;

	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);
	for (;;) {
		if (isatty(0)) {
			fputs("uicc> ", stdout);
			fflush(stdout);
		}
		if (!fgets(command, sizeof command, stdin))
			good_exit();
		simtool_dispatch_cmd(command, 0);
	}
}