comparison loadtools/ltexit.c @ 28:768a3d012931

loadtool: default exit mode setting implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 04 May 2013 06:39:05 +0000
parents ae6294b8a015
children 6f8d3771aa6c
comparison
equal deleted inserted replaced
27:ae6294b8a015 28:768a3d012931
51 argv[1]); 51 argv[1]);
52 return(-1); 52 return(-1);
53 } 53 }
54 tp->func(); 54 tp->func();
55 } 55 }
56
57 /* called from hwparam.c config file parser */
58 void
59 set_default_exit_mode(arg, filename_for_errs, lineno_for_errs)
60 char *arg;
61 char *filename_for_errs;
62 int lineno_for_errs;
63 {
64 char *cp;
65 struct kwtab *tp;
66
67 while (isspace(*arg))
68 arg++;
69 if (!*arg) {
70 fprintf(stderr,
71 "%s line %d: exit-mode setting requires an argument\n",
72 filename_for_errs, lineno_for_errs);
73 exit(1);
74 }
75 for (cp = arg; *cp && !isspace(*cp); cp++)
76 ;
77 *cp = '\0';
78 for (tp = exit_modes; tp->kw; tp++)
79 if (!strcmp(tp->kw, arg))
80 break;
81 if (!tp->func) {
82 fprintf(stderr,
83 "%s line %d: \"%s\" is not an understood exit mode\n",
84 filename_for_errs, lineno_for_errs, arg);
85 exit(1);
86 }
87 default_exit = tp->func;
88 }