wpa_cli: Completion routine for dup_network command

Add command completion routine for dup_network command.

Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sonymobile.com>
This commit is contained in:
Mikael Kanstrup 2015-03-24 17:10:40 +01:00 committed by Jouni Malinen
parent 1ca6c0f1f1
commit 5a997b2f79

View file

@ -1646,6 +1646,31 @@ static int wpa_cli_cmd_dup_network(struct wpa_ctrl *ctrl, int argc,
} }
static char ** wpa_cli_complete_dup_network(const char *str, int pos)
{
int arg = get_cmd_arg_num(str, pos);
int i, num_fields = ARRAY_SIZE(network_fields);
char **res = NULL;
switch (arg) {
case 1:
case 2:
res = cli_txt_list_array(&networks);
break;
case 3:
res = os_calloc(num_fields + 1, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; i < num_fields; i++) {
res[i] = os_strdup(network_fields[i]);
if (res[i] == NULL)
break;
}
}
return res;
}
static int wpa_cli_cmd_list_creds(struct wpa_ctrl *ctrl, int argc, static int wpa_cli_cmd_list_creds(struct wpa_ctrl *ctrl, int argc,
char *argv[]) char *argv[])
{ {
@ -2911,7 +2936,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "get_network", wpa_cli_cmd_get_network, wpa_cli_complete_network, { "get_network", wpa_cli_cmd_get_network, wpa_cli_complete_network,
cli_cmd_flag_none, cli_cmd_flag_none,
"<network id> <variable> = get network variables" }, "<network id> <variable> = get network variables" },
{ "dup_network", wpa_cli_cmd_dup_network, NULL, { "dup_network", wpa_cli_cmd_dup_network, wpa_cli_complete_dup_network,
cli_cmd_flag_none, cli_cmd_flag_none,
"<src network id> <dst network id> <variable> = duplicate network variables" "<src network id> <dst network id> <variable> = duplicate network variables"
}, },