]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
cli: Share a common get_cmd_arg_num() implementation
authorJouni Malinen <j@w1.fi>
Sat, 6 Aug 2016 09:39:56 +0000 (12:39 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 6 Aug 2016 09:39:56 +0000 (12:39 +0300)
wpa_cli and hostapd_cli had identical copies of this function.

Signed-off-by: Jouni Malinen <j@w1.fi>
hostapd/hostapd_cli.c
src/common/cli.c
src/common/cli.h
wpa_supplicant/wpa_cli.c

index 376a02572496b7e154e53a7626fa6e1a1f8a2855..56f5fe25105d6d1f2e1f52b29cd389df4efdac21 100644 (file)
@@ -74,24 +74,6 @@ 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 void register_event_handler(struct wpa_ctrl *ctrl)
 {
        if (!ctrl_conn)
index 24f465ca5025054ceb9965b03a63a0955d0ea178..6e0018875db4036f8cd57498bc6b418aa9b67de2 100644 (file)
@@ -188,3 +188,21 @@ char ** cli_txt_list_array(struct dl_list *txt_list)
 
        return res;
 }
+
+
+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;
+}
index 4b44ce27d43385654cfd95b58841c64f32cd145d..4caf321c4956a89103b8ef9926e941996b275511 100644 (file)
@@ -37,4 +37,6 @@ int cli_txt_list_add_word(struct dl_list *txt_list, const char *txt,
 
 char ** cli_txt_list_array(struct dl_list *txt_list);
 
+int get_cmd_arg_num(const char *str, int pos);
+
 #endif /* CLI_H */
index 7614218126dad2bfc21c77d3bb964282f3478dfc..42be5b6f64d5fc82506019d6240ff0581a902693 100644 (file)
@@ -90,24 +90,6 @@ 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 wpa_cli_show_event(const char *event)
 {
        const char *start;