mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-16 15:20:42 +01:00
client: Unify device sibling interface arg completion
Station, WSC, Ad-Hoc and AP family_arg_completion functions were identical except for which commands they were referencing and the interface type they were interested in. Combine all these into a single function.
This commit is contained in:
parent
d347100ac2
commit
405de7019c
@ -229,31 +229,8 @@ static const struct command ad_hoc_commands[] = {
|
|||||||
|
|
||||||
static char *family_arg_completion(const char *text, int state)
|
static char *family_arg_completion(const char *text, int state)
|
||||||
{
|
{
|
||||||
static bool first_pass;
|
return device_arg_completion(text, state, ad_hoc_commands,
|
||||||
static size_t index;
|
IWD_AD_HOC_INTERFACE);
|
||||||
static size_t len;
|
|
||||||
const char *cmd;
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
index = 0;
|
|
||||||
len = strlen(text);
|
|
||||||
first_pass = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((cmd = ad_hoc_commands[index].cmd)) {
|
|
||||||
if (ad_hoc_commands[index++].entity)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strncmp(cmd, text, len))
|
|
||||||
return l_strdup(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_pass) {
|
|
||||||
state = 0;
|
|
||||||
first_pass = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return device_ad_hoc_family_arg_completion(text, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entity_arg_completion(const char *text, int state)
|
static char *entity_arg_completion(const char *text, int state)
|
||||||
|
27
client/ap.c
27
client/ap.c
@ -201,31 +201,8 @@ static const struct command ap_commands[] = {
|
|||||||
|
|
||||||
static char *family_arg_completion(const char *text, int state)
|
static char *family_arg_completion(const char *text, int state)
|
||||||
{
|
{
|
||||||
static bool first_pass;
|
return device_arg_completion(text, state, ap_commands,
|
||||||
static size_t index;
|
IWD_ACCESS_POINT_INTERFACE);
|
||||||
static size_t len;
|
|
||||||
const char *cmd;
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
index = 0;
|
|
||||||
len = strlen(text);
|
|
||||||
first_pass = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((cmd = ap_commands[index].cmd)) {
|
|
||||||
if (ap_commands[index++].entity)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strncmp(cmd, text, len))
|
|
||||||
return l_strdup(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_pass) {
|
|
||||||
state = 0;
|
|
||||||
first_pass = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return device_ap_family_arg_completion(text, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entity_arg_completion(const char *text, int state)
|
static char *entity_arg_completion(const char *text, int state)
|
||||||
|
@ -435,39 +435,9 @@ static const struct command device_commands[] = {
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
char *device_wsc_family_arg_completion(const char *text, int state)
|
char *device_arg_completion(const char *text, int state,
|
||||||
{
|
const struct command *commands,
|
||||||
return proxy_property_str_completion(&device_interface_type,
|
const char *extra_interface)
|
||||||
match_by_partial_name,
|
|
||||||
"Name", text, state,
|
|
||||||
IWD_WSC_INTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *device_ap_family_arg_completion(const char *text, int state)
|
|
||||||
{
|
|
||||||
return proxy_property_str_completion(&device_interface_type,
|
|
||||||
match_by_partial_name,
|
|
||||||
"Name", text, state,
|
|
||||||
IWD_ACCESS_POINT_INTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *device_ad_hoc_family_arg_completion(const char *text, int state)
|
|
||||||
{
|
|
||||||
return proxy_property_str_completion(&device_interface_type,
|
|
||||||
match_by_partial_name,
|
|
||||||
"Name", text, state,
|
|
||||||
IWD_AD_HOC_INTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *device_station_family_arg_completion(const char *text, int state)
|
|
||||||
{
|
|
||||||
return proxy_property_str_completion(&device_interface_type,
|
|
||||||
match_by_partial_name,
|
|
||||||
"Name", text, state,
|
|
||||||
IWD_STATION_INTERFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *family_arg_completion(const char *text, int state)
|
|
||||||
{
|
{
|
||||||
static bool first_pass;
|
static bool first_pass;
|
||||||
static size_t index;
|
static size_t index;
|
||||||
@ -480,8 +450,8 @@ static char *family_arg_completion(const char *text, int state)
|
|||||||
first_pass = true;
|
first_pass = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((cmd = device_commands[index].cmd)) {
|
while ((cmd = commands[index].cmd)) {
|
||||||
if (device_commands[index++].entity)
|
if (commands[index++].entity)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!strncmp(cmd, text, len))
|
if (!strncmp(cmd, text, len))
|
||||||
@ -495,7 +465,12 @@ static char *family_arg_completion(const char *text, int state)
|
|||||||
|
|
||||||
return proxy_property_str_completion(&device_interface_type,
|
return proxy_property_str_completion(&device_interface_type,
|
||||||
match_by_partial_name, "Name",
|
match_by_partial_name, "Name",
|
||||||
text, state, NULL);
|
text, state, extra_interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *family_arg_completion(const char *text, int state)
|
||||||
|
{
|
||||||
|
return device_arg_completion(text, state, device_commands, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entity_arg_completion(const char *text, int state)
|
static char *entity_arg_completion(const char *text, int state)
|
||||||
|
@ -22,10 +22,9 @@
|
|||||||
|
|
||||||
struct proxy_interface;
|
struct proxy_interface;
|
||||||
|
|
||||||
char *device_wsc_family_arg_completion(const char *text, int state);
|
char *device_arg_completion(const char *text, int state,
|
||||||
char *device_ap_family_arg_completion(const char *text, int state);
|
const struct command *commands,
|
||||||
char *device_ad_hoc_family_arg_completion(const char *text, int state);
|
const char *extra_interface);
|
||||||
char *device_station_family_arg_completion(const char *text, int state);
|
|
||||||
|
|
||||||
const struct proxy_interface *device_proxy_find_by_name(const char *name);
|
const struct proxy_interface *device_proxy_find_by_name(const char *name);
|
||||||
const struct proxy_interface *device_proxy_find(const char *device_name,
|
const struct proxy_interface *device_proxy_find(const char *device_name,
|
||||||
|
@ -494,31 +494,8 @@ static const struct command station_commands[] = {
|
|||||||
|
|
||||||
static char *family_arg_completion(const char *text, int state)
|
static char *family_arg_completion(const char *text, int state)
|
||||||
{
|
{
|
||||||
static bool first_pass;
|
return device_arg_completion(text, state, station_commands,
|
||||||
static size_t index;
|
IWD_STATION_INTERFACE);
|
||||||
static size_t len;
|
|
||||||
const char *cmd;
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
index = 0;
|
|
||||||
len = strlen(text);
|
|
||||||
first_pass = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((cmd = station_commands[index].cmd)) {
|
|
||||||
if (station_commands[index++].entity)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strncmp(cmd, text, len))
|
|
||||||
return l_strdup(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_pass) {
|
|
||||||
state = 0;
|
|
||||||
first_pass = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return device_station_family_arg_completion(text, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entity_arg_completion(const char *text, int state)
|
static char *entity_arg_completion(const char *text, int state)
|
||||||
|
27
client/wsc.c
27
client/wsc.c
@ -214,31 +214,8 @@ static const struct command wsc_commands[] = {
|
|||||||
|
|
||||||
static char *family_arg_completion(const char *text, int state)
|
static char *family_arg_completion(const char *text, int state)
|
||||||
{
|
{
|
||||||
static bool first_pass;
|
return device_arg_completion(text, state, wsc_commands,
|
||||||
static size_t index;
|
IWD_WSC_INTERFACE);
|
||||||
static size_t len;
|
|
||||||
const char *cmd;
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
index = 0;
|
|
||||||
len = strlen(text);
|
|
||||||
first_pass = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((cmd = wsc_commands[index].cmd)) {
|
|
||||||
if (wsc_commands[index++].entity)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strncmp(cmd, text, len))
|
|
||||||
return l_strdup(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first_pass) {
|
|
||||||
state = 0;
|
|
||||||
first_pass = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return device_wsc_family_arg_completion(text, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entity_arg_completion(const char *text, int state)
|
static char *entity_arg_completion(const char *text, int state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user