comparison uicc/main.c @ 78:f6d5cff989d6

fc-uicc-tool batch stdin mode implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 09 Apr 2021 02:47:21 +0000
parents e2ef4b8e4136
children
comparison
equal deleted inserted replaced
77:3fe1954f5dec 78:f6d5cff989d6
9 main(argc, argv) 9 main(argc, argv)
10 char **argv; 10 char **argv;
11 { 11 {
12 extern int optind; 12 extern int optind;
13 char command[512]; 13 char command[512];
14 int rc; 14 int rc, batch_stdin;
15 15
16 parse_global_options(argc, argv); 16 parse_global_options(argc, argv);
17 launch_backend(); 17 launch_backend();
18 collect_backend_init_strings(); 18 collect_backend_init_strings();
19 if (argc > optind) { 19 if (argc > optind) {
27 printf("Card reader name: %s\n", be_reader_name); 27 printf("Card reader name: %s\n", be_reader_name);
28 if (be_atr_string[0]) 28 if (be_atr_string[0])
29 printf("ATR: %s\n", be_atr_string); 29 printf("ATR: %s\n", be_atr_string);
30 if (be_extra_info[0]) 30 if (be_extra_info[0])
31 puts(be_extra_info); 31 puts(be_extra_info);
32 batch_stdin = !isatty(0);
32 for (;;) { 33 for (;;) {
33 if (isatty(0)) { 34 if (!batch_stdin) {
34 fputs("uicc> ", stdout); 35 fputs("uicc> ", stdout);
35 fflush(stdout); 36 fflush(stdout);
36 } 37 }
37 if (!fgets(command, sizeof command, stdin)) 38 if (!fgets(command, sizeof command, stdin))
38 good_exit(); 39 good_exit();
39 simtool_dispatch_cmd(command, 0); 40 if (batch_stdin)
41 printf("Stdin command: %s", command);
42 rc = simtool_dispatch_cmd(command, 0);
43 if (batch_stdin && rc)
44 exit(1);
40 } 45 }
41 } 46 }