comparison loadtools/ltexit.c @ 229:96332d875fc9

loadtools: preparations for loadtool exit code possibly being nonzero
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 03 Aug 2017 01:33:06 +0000
parents e7502631a0f9
children aba969153d20
comparison
equal deleted inserted replaced
228:ccf5edab9d5f 229:96332d875fc9
7 #include <string.h> 7 #include <string.h>
8 #include <strings.h> 8 #include <strings.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 static void 11 static void
12 exit_bare() 12 exit_bare(rc)
13 { 13 {
14 exit(0); 14 exit(rc);
15 } 15 }
16 16
17 static void 17 static void
18 exit_gta02_cutpwr() 18 exit_gta02_cutpwr(rc)
19 { 19 {
20 #ifdef GTA0x_AP_BUILD 20 #ifdef GTA0x_AP_BUILD
21 set_gta_modem_power_ctrl(0); 21 set_gta_modem_power_ctrl(0);
22 #endif 22 #endif
23 exit(0); 23 exit(rc);
24 } 24 }
25 25
26 static void 26 static void
27 exit_iotaoff() 27 exit_iotaoff(rc)
28 { 28 {
29 static char *poweroff_argv[2] = {"poweroff", 0}; 29 static char *poweroff_argv[2] = {"poweroff", 0};
30 30
31 tpinterf_make_cmd(poweroff_argv); 31 tpinterf_make_cmd(poweroff_argv);
32 tpinterf_send_cmd(); 32 tpinterf_send_cmd();
33 exit(0); 33 exit(rc);
34 } 34 }
35 35
36 static void 36 static void
37 exit_jump0() 37 exit_jump0(rc)
38 { 38 {
39 static char *jump0_argv[3] = {"jump", "0", 0}; 39 static char *jump0_argv[3] = {"jump", "0", 0};
40 40
41 tpinterf_make_cmd(jump0_argv); 41 tpinterf_make_cmd(jump0_argv);
42 tpinterf_send_cmd(); 42 tpinterf_send_cmd();
43 exit(0); 43 exit(rc);
44 } 44 }
45 45
46 void (*default_exit)() = exit_bare; 46 void (*default_exit)() = exit_bare;
47 47
48 static struct kwtab { 48 static struct kwtab {
60 char **argv; 60 char **argv;
61 { 61 {
62 struct kwtab *tp; 62 struct kwtab *tp;
63 63
64 if (argc < 2) 64 if (argc < 2)
65 default_exit(); 65 default_exit(0);
66 for (tp = exit_modes; tp->kw; tp++) 66 for (tp = exit_modes; tp->kw; tp++)
67 if (!strcmp(tp->kw, argv[1])) 67 if (!strcmp(tp->kw, argv[1]))
68 break; 68 break;
69 if (!tp->func) { 69 if (!tp->func) {
70 fprintf(stderr, 70 fprintf(stderr,
71 "error: \"%s\" is not an understood exit mode\n", 71 "error: \"%s\" is not an understood exit mode\n",
72 argv[1]); 72 argv[1]);
73 return(-1); 73 return(-1);
74 } 74 }
75 tp->func(); 75 tp->func(0);
76 } 76 }
77 77
78 /* called from hwparam.c config file parser */ 78 /* called from hwparam.c config file parser */
79 void 79 void
80 set_default_exit_mode(arg, filename_for_errs, lineno_for_errs) 80 set_default_exit_mode(arg, filename_for_errs, lineno_for_errs)