eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 405de7019c2a906c7ebdba85b1f440e28c98caa5
parent d347100ac2d25e80da9dae38c65d60497bb9bf2f
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Fri, 14 Sep 2018 22:58:10 -0500

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.

Diffstat:
Mclient/ad-hoc.c | 27++-------------------------
Mclient/ap.c | 27++-------------------------
Mclient/device.c | 47+++++++++++------------------------------------
Mclient/device.h | 7+++----
Mclient/station.c | 27++-------------------------
Mclient/wsc.c | 27++-------------------------
6 files changed, 22 insertions(+), 140 deletions(-)

diff --git a/client/ad-hoc.c b/client/ad-hoc.c @@ -229,31 +229,8 @@ static const struct command ad_hoc_commands[] = { static char *family_arg_completion(const char *text, int state) { - static bool first_pass; - static size_t index; - 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); + return device_arg_completion(text, state, ad_hoc_commands, + IWD_AD_HOC_INTERFACE); } static char *entity_arg_completion(const char *text, int state) diff --git a/client/ap.c b/client/ap.c @@ -201,31 +201,8 @@ static const struct command ap_commands[] = { static char *family_arg_completion(const char *text, int state) { - static bool first_pass; - static size_t index; - 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); + return device_arg_completion(text, state, ap_commands, + IWD_ACCESS_POINT_INTERFACE); } static char *entity_arg_completion(const char *text, int state) diff --git a/client/device.c b/client/device.c @@ -435,39 +435,9 @@ static const struct command device_commands[] = { { } }; -char *device_wsc_family_arg_completion(const char *text, int state) -{ - return proxy_property_str_completion(&device_interface_type, - 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) +char *device_arg_completion(const char *text, int state, + const struct command *commands, + const char *extra_interface) { static bool first_pass; static size_t index; @@ -480,8 +450,8 @@ static char *family_arg_completion(const char *text, int state) first_pass = true; } - while ((cmd = device_commands[index].cmd)) { - if (device_commands[index++].entity) + while ((cmd = commands[index].cmd)) { + if (commands[index++].entity) continue; 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, 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) diff --git a/client/device.h b/client/device.h @@ -22,10 +22,9 @@ struct proxy_interface; -char *device_wsc_family_arg_completion(const char *text, int state); -char *device_ap_family_arg_completion(const char *text, int state); -char *device_ad_hoc_family_arg_completion(const char *text, int state); -char *device_station_family_arg_completion(const char *text, int state); +char *device_arg_completion(const char *text, int state, + const struct command *commands, + const char *extra_interface); const struct proxy_interface *device_proxy_find_by_name(const char *name); const struct proxy_interface *device_proxy_find(const char *device_name, diff --git a/client/station.c b/client/station.c @@ -494,31 +494,8 @@ static const struct command station_commands[] = { static char *family_arg_completion(const char *text, int state) { - static bool first_pass; - static size_t index; - 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); + return device_arg_completion(text, state, station_commands, + IWD_STATION_INTERFACE); } static char *entity_arg_completion(const char *text, int state) diff --git a/client/wsc.c b/client/wsc.c @@ -214,31 +214,8 @@ static const struct command wsc_commands[] = { static char *family_arg_completion(const char *text, int state) { - static bool first_pass; - static size_t index; - 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); + return device_arg_completion(text, state, wsc_commands, + IWD_WSC_INTERFACE); } static char *entity_arg_completion(const char *text, int state)