comparison uicc/script.c @ 130:f691a19f191d

fc-uicc-tool skeleton started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Feb 2021 00:08:12 +0000
parents
children
comparison
equal deleted inserted replaced
129:2adb802b2a98 130:f691a19f191d
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 }