comparison loadtools/ltexit.c @ 27:ae6294b8a015

loadtool: exit jump0 implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 04 May 2013 06:22:09 +0000
parents
children 768a3d012931
comparison
equal deleted inserted replaced
26:1a3bbab2ea26 27:ae6294b8a015
1 /*
2 * This module implements the loadtool exit command, along with its
3 * options for jump-reboot or eventual Iota power-off.
4 */
5
6 #include <stdio.h>
7 #include <string.h>
8 #include <strings.h>
9 #include <stdlib.h>
10
11 static void
12 exit_bare()
13 {
14 exit(0);
15 }
16
17 static void
18 exit_jump0()
19 {
20 static char *jump0_argv[3] = {"jump", "0", 0};
21
22 tpinterf_make_cmd(jump0_argv);
23 tpinterf_send_cmd();
24 exit(0);
25 }
26
27 void (*default_exit)() = exit_bare;
28
29 static struct kwtab {
30 char *kw;
31 void (*func)();
32 } exit_modes[] = {
33 {"bare", exit_bare},
34 {"jump0", exit_jump0},
35 {0, 0}
36 };
37
38 cmd_exit(argc, argv)
39 char **argv;
40 {
41 struct kwtab *tp;
42
43 if (argc < 2)
44 default_exit();
45 for (tp = exit_modes; tp->kw; tp++)
46 if (!strcmp(tp->kw, argv[1]))
47 break;
48 if (!tp->func) {
49 fprintf(stderr,
50 "error: \"%s\" is not an understood exit mode\n",
51 argv[1]);
52 return(-1);
53 }
54 tp->func();
55 }