annotate simtool/main.c @ 173:df4bf4e06221

doc: several articles moved to other repositories
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Sep 2023 06:51:05 +0000
parents 6c4567dd8946
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
85
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdio.h>
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <pcsclite.h>
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <winscard.h>
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "globals.h"
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 main(argc, argv)
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char **argv;
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 char command[512];
124
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
12 int rc;
85
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 setup_pcsc_context();
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 get_reader_name();
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 printf("Card reader name: %s\n", reader_name_buf);
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 connect_to_card();
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 retrieve_atr();
124
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
19 if (argc >= 2) {
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
20 rc = dispatch_ready_argv(argc - 1, argv + 1);
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
21 if (rc)
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
22 error_exit();
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
23 else
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
24 good_exit();
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
25 }
85
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 for (;;) {
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (isatty(0)) {
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fputs("simtool> ", stdout);
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 fflush(stdout);
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (!fgets(command, sizeof command, stdin))
124
6c4567dd8946 fc-simtool: add non-interactive one-shot command (or script) mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 123
diff changeset
32 good_exit();
123
b391204d3cd5 fc-simtool: add scripting facility in the form of exec command
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
33 simtool_dispatch_cmd(command, 0);
85
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
b57cf64ece29 fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }