annotate libcommon/be_init.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 e2ef4b8e4136
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 /*
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module is responsible for collecting the initial info
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * strings emitted by the back end.
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
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 #include <ctype.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 extern FILE *rpipeF;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #define MAX_INIT_STRING 254
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char be_reader_name[MAX_INIT_STRING+1];
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char be_atr_string[MAX_INIT_STRING+1];
46
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
18 char be_extra_info[MAX_INIT_STRING+1];
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 static void
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 copy_without_leading_space(input_str, dest)
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char *input_str, *dest;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 char *cp;
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 for (cp = input_str; isspace(*cp); cp++)
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 strcpy(dest, cp);
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
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 collect_backend_init_strings()
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 char inbuf[MAX_INIT_STRING+2], *cp;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 for (;;) {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (!fgets(inbuf, sizeof inbuf, rpipeF)) {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 fprintf(stderr,
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 "start-up error: EOF reading init strings from back end\n");
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 cp = index(inbuf, '\n');
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!cp) {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr,
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 "start-up error: init string from back end has no newline\n");
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 exit(1);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *cp = '\0';
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (!inbuf[0])
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 break;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 switch (inbuf[0]) {
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 case 'A':
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 copy_without_leading_space(inbuf + 1, be_atr_string);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 break;
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 case 'R':
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 copy_without_leading_space(inbuf + 1, be_reader_name);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 break;
46
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
57 case 'X':
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
58 copy_without_leading_space(inbuf + 1, be_extra_info);
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
59 break;
9
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 }
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return(0);
c9ef9e91dd8e new libcommon, initial version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }