annotate uicc/main.c @ 169:17ffa6c66951

ee2232/README: update deprecation notice, point at the current version in fc-usbser-tools
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Sep 2023 04:17:09 +0000
parents f691a19f191d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
130
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdio.h>
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <pcsclite.h>
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <winscard.h>
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "globals.h"
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 main(argc, argv)
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char **argv;
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 char command[512];
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 int rc;
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 setup_pcsc_context();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 get_reader_name();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 printf("Card reader name: %s\n", reader_name_buf);
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 connect_to_card();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 retrieve_atr();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (argc >= 2) {
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 rc = dispatch_ready_argv(argc - 1, argv + 1);
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (rc)
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 error_exit();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 else
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 good_exit();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 for (;;) {
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (isatty(0)) {
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fputs("uicc> ", stdout);
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 fflush(stdout);
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (!fgets(command, sizeof command, stdin))
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 good_exit();
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 simtool_dispatch_cmd(command, 0);
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
f691a19f191d fc-uicc-tool skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }