diff options
author | andmarti1424 <andmarti@gmail.com> | 2017-05-05 20:41:10 -0300 |
---|---|---|
committer | andmarti1424 <andmarti@gmail.com> | 2017-05-05 20:41:10 -0300 |
commit | ba151b06ae7d13e7cb17ab933dde4c5df8228b2b (patch) | |
tree | 61881f7ec8450faeac208857798c7ca957d2c1d7 | |
parent | c7f8736bb2f24cf1ebeb30ddc5e51c29b661eef0 (diff) |
Add validation to set command
-rw-r--r-- | src/cmds_command.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c index 4b9176a..7bf5fcd 100644 --- a/src/cmds_command.c +++ b/src/cmds_command.c @@ -683,9 +683,21 @@ void do_commandmode(struct block * sb) { wcscpy(interp_line, inputline); send_to_interp(interp_line); } else if ( ! wcsncmp(inputline, L"set ", 4) ) { - wcscpy(interp_line, inputline); - send_to_interp(interp_line); - sc_info("Config value changed: %s", line); + + wchar_t line [BUFFERSIZE]; + wcscpy(line, inputline); + del_range_wchars(line, 0, 3); + wchar_t * l; + char oper[BUFFERSIZE]; + if ((l = wcschr(line, L' ')) != NULL) l[0] = L'\0'; + if ((l = wcschr(line, L'=')) != NULL) l[0] = L'\0'; + wcstombs(oper, line, BUFFERSIZE); + if (get_conf_value(oper)) { + sc_info("Config value changed: %s", oper); + wcscpy(interp_line, inputline); + send_to_interp(interp_line); + } else + sc_error("Invalid configuration parameter"); } else if ( ! wcsncmp(inputline, L"pad ", 4) ) { int c = curcol, cf = curcol; |