diff options
Diffstat (limited to 'usr.sbin/sysinstall/dispatch.c')
-rw-r--r-- | usr.sbin/sysinstall/dispatch.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c index a41a724..75f1a52 100644 --- a/usr.sbin/sysinstall/dispatch.c +++ b/usr.sbin/sysinstall/dispatch.c @@ -37,6 +37,8 @@ #include "sysinstall.h" #include <ctype.h> +static int _shutdown(dialogMenuItem *unused); + static struct _word { char *name; int (*handler)(dialogMenuItem *self); @@ -85,6 +87,7 @@ static struct _word { { "optionsEditor", optionsEditor }, { "addGroup", userAddGroup }, { "addUser", userAddUser }, + { "shutdown", _shutdown }, { NULL, NULL }, }; @@ -104,6 +107,13 @@ call_possible_resword(char *name, dialogMenuItem *value, int *status) return rval; } +/* Just convenience */ +static int _shutdown(dialogMenuItem *unused) +{ + systemShutdown(0); + return DITEM_FAILURE; +} + /* For a given string, call it or spit out an undefined command diagnostic */ int dispatchCommand(char *str) @@ -115,16 +125,22 @@ dispatchCommand(char *str) msgConfirm("Null or zero-length string passed to dispatchCommand"); return DITEM_FAILURE; } + /* If it's got a newline, trim it */ + if ((cp = index(str, '\n')) != NULL) + *cp = '\0'; + /* A command might be a pathname if it's encoded in argv[0], as we also support */ if (index(str, '=')) { variable_set(str); - return DITEM_SUCCESS; + i = DITEM_SUCCESS; } - else if ((cp = index(str, '/')) != NULL) - str = cp + 1; - if (!call_possible_resword(str, NULL, &i)) { - msgConfirm("No such command: %s", str); - return DITEM_FAILURE; + else { + if ((cp = index(str, '/')) != NULL) + str = cp + 1; + if (!call_possible_resword(str, NULL, &i)) { + msgConfirm("No such command: %s", str); + i = DITEM_FAILURE; + } } return i; } |