FreeCalypso > hg > fc-pcsc-tools
comparison uicc/script.c @ 22:1b1468869ccf
new trimmed fc-uicc-tool is here
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 12 Feb 2021 04:34:53 +0000 |
parents | |
children | ede661d78730 |
comparison
equal
deleted
inserted
replaced
21:d4dc86195382 | 22:1b1468869ccf |
---|---|
1 /* | |
2 * This module implements the exec command, which is our scripting facility. | |
3 */ | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
8 #include <strings.h> | |
9 | |
10 cmd_exec(argc, argv) | |
11 char **argv; | |
12 { | |
13 FILE *f; | |
14 char linebuf[512], *cp; | |
15 int lineno, retval = 0; | |
16 | |
17 f = fopen(argv[1], "r"); | |
18 if (!f) { | |
19 perror(argv[1]); | |
20 return(-1); | |
21 } | |
22 for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) { | |
23 cp = index(linebuf, '\n'); | |
24 if (!cp) { | |
25 fprintf(stderr, "%s line %d: missing newline\n", | |
26 argv[1], lineno); | |
27 fclose(f); | |
28 return(-1); | |
29 } | |
30 *cp = '\0'; | |
31 retval = simtool_dispatch_cmd(linebuf, 1); | |
32 if (retval) | |
33 break; | |
34 } | |
35 fclose(f); | |
36 return(retval); | |
37 } |