aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/hostapd_cli.c
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@sonymobile.com>2016-07-07 12:04:33 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-06 09:18:07 (GMT)
commit6cad0bff069f06b6a08539f5b03ba04ab0f91d43 (patch)
treeb0ed84d6b4333060006184499771ddd635e01399 /hostapd/hostapd_cli.c
parent01938838b5f1940d53fc8377a5fc3948288eb49e (diff)
downloadhostap-6cad0bff069f06b6a08539f5b03ba04ab0f91d43.zip
hostap-6cad0bff069f06b6a08539f5b03ba04ab0f91d43.tar.gz
hostap-6cad0bff069f06b6a08539f5b03ba04ab0f91d43.tar.bz2
hostapd_cli: Add completion for help command
Implement command completion support for help command. Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sonymobile.com>
Diffstat (limited to 'hostapd/hostapd_cli.c')
-rw-r--r--hostapd/hostapd_cli.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 0212335..2a45ca4 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -75,6 +75,7 @@ static int ping_interval = 5;
static int interactive = 0;
static void print_help(FILE *stream, const char *cmd);
+static char ** list_cmd_list(void);
static void usage(void)
@@ -104,6 +105,24 @@ static void usage(void)
}
+static int get_cmd_arg_num(const char *str, int pos)
+{
+ int arg = 0, i;
+
+ for (i = 0; i <= pos; i++) {
+ if (str[i] != ' ') {
+ arg++;
+ while (i <= pos && str[i] != ' ')
+ i++;
+ }
+ }
+
+ if (arg > 0)
+ arg--;
+ return arg;
+}
+
+
static int str_starts(const char *src, const char *match)
{
return os_strncmp(src, match, os_strlen(match)) == 0;
@@ -754,6 +773,21 @@ static int hostapd_cli_cmd_help(struct wpa_ctrl *ctrl, int argc, char *argv[])
}
+static char ** hostapd_cli_complete_help(const char *str, int pos)
+{
+ int arg = get_cmd_arg_num(str, pos);
+ char **res = NULL;
+
+ switch (arg) {
+ case 1:
+ res = list_cmd_list();
+ break;
+ }
+
+ return res;
+}
+
+
static int hostapd_cli_cmd_license(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -1259,7 +1293,7 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "bss_tm_req", hostapd_cli_cmd_bss_tm_req, NULL, NULL },
{ "get_config", hostapd_cli_cmd_get_config, NULL,
"= show current configuration" },
- { "help", hostapd_cli_cmd_help, NULL,
+ { "help", hostapd_cli_cmd_help, hostapd_cli_complete_help,
"= show this usage help" },
{ "interface", hostapd_cli_cmd_interface, NULL,
"[ifname] = show interfaces/select interface" },