diff options
Diffstat (limited to 'src/syscmd.c')
| -rw-r--r-- | src/syscmd.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/syscmd.c b/src/syscmd.c index 6c3d2e5..8c3a88a 100644 --- a/src/syscmd.c +++ b/src/syscmd.c @@ -19,18 +19,59 @@ */ #include <config.h> +#include <string.h> #include "syscmd.h" +#include "nls.h" + +static void syscmd_version(struct aplwc *, struct aplwc_syscmd *, char *); +static void syscmd_exit(struct aplwc *, struct aplwc_syscmd *, char *); +static void syscmd_stats(struct aplwc *, struct aplwc_syscmd *, char *); static struct aplwc_syscmd syscmds[] = { - {.name = "help"}, - {.name = "version"}, - {.name = "reset"}, - {.name = "exit"}, + { + .name = "version", + .run = syscmd_version + }, + { + .name = "exit", + .run = syscmd_exit + }, + { + .name = "stats", + .run = syscmd_stats + }, }; void init_syscmds(struct aplwc *aplwc) { - for(int i = 0; i < (sizeof(syscmds)/sizeof(*syscmds)); i++) + for(size_t i = 0; i < (sizeof(syscmds)/sizeof(*syscmds)); i++) aplwc_register_syscmd(aplwc, &syscmds[i]); } + +static void +syscmd_version(struct aplwc *aplwc, struct aplwc_syscmd *syscmd, char *input) +{ + if(strlen(input) > 0) + aplwc_syscmd_error(aplwc, syscmd, _("Unexpected: %s")); + else + aplwc_syscmd_output(aplwc, syscmd, _("Version 0")); +} + +static void +syscmd_exit(struct aplwc *aplwc, struct aplwc_syscmd *syscmd, char *input) +{ + if(strlen(input) > 0) + aplwc_syscmd_error(aplwc, syscmd, _("Unexpected: %s")); + else + aplwc_exit(aplwc); +} + +static void +syscmd_stats(struct aplwc *aplwc, struct aplwc_syscmd *syscmd, char *input) +{ + if(strlen(input) > 0) + aplwc_syscmd_error(aplwc, syscmd, _("Unexpected: %s")); + else + aplwc_syscmd_output(aplwc, syscmd, _("Stats...\nMore stats...")); +} |