FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- a/loadtools/ltexit.c Sat May 04 06:22:09 2013 +0000 +++ b/loadtools/ltexit.c Sat May 04 06:39:05 2013 +0000 @@ -53,3 +53,36 @@ } tp->func(); } + +/* called from hwparam.c config file parser */ +void +set_default_exit_mode(arg, filename_for_errs, lineno_for_errs) + char *arg; + char *filename_for_errs; + int lineno_for_errs; +{ + char *cp; + struct kwtab *tp; + + while (isspace(*arg)) + arg++; + if (!*arg) { + fprintf(stderr, + "%s line %d: exit-mode setting requires an argument\n", + filename_for_errs, lineno_for_errs); + exit(1); + } + for (cp = arg; *cp && !isspace(*cp); cp++) + ; + *cp = '\0'; + for (tp = exit_modes; tp->kw; tp++) + if (!strcmp(tp->kw, arg)) + break; + if (!tp->func) { + fprintf(stderr, + "%s line %d: \"%s\" is not an understood exit mode\n", + filename_for_errs, lineno_for_errs, arg); + exit(1); + } + default_exit = tp->func; +}