annotate libcommon/exit.c @ 93:6041c601304d

fcsim1-mkprov: revert OTA key addition It appears that GrcardSIM2 cards (which is what we got for FCSIM1) do not support OTA after all, contrary to what we were previously led to believe by some tech support emails from Grcard - apparently those support emails and OTA descriptions referred to some other card model(s).
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 21 Apr 2021 05:38:39 +0000
parents 812779459ddd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <stdio.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdlib.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <string.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <strings.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 extern unsigned calypso_fd;
54
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
7 extern FILE *cpipeF, *rpipeF;
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
8
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
9 calypso_poweroff()
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
10 {
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
11 int c;
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
12
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
13 fputs("poweroff\n", cpipeF);
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
14 fflush(cpipeF);
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
15 while ((c = getc(rpipeF)) != EOF)
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
16 putchar(c);
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
17 exit(0);
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
18 }
9
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 good_exit()
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
54
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
22 if (calypso_fd)
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
23 calypso_poweroff();
9
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 exit(0);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd_exit(argc, argv)
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char **argv;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (argc < 2)
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 good_exit();
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (!calypso_fd) {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fprintf(stderr,
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 "error: exit arguments are only meaningful with Calypso back end\n");
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return(-1);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!strcmp(argv[1], "bare"))
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 exit(0);
54
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
39 if (!strcmp(argv[1], "iota-off"))
812779459ddd Calypso exit mode: show any output from back end
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
40 calypso_poweroff();
9
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 fprintf(stderr, "error: \"%s\" is not an understood exit mode\n",
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 argv[1]);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return(-1);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }