[PATCH 3/5] wlantest: remove the duplicate functions & reuse the definitions from cli.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The definitions of max_args, get_cmd_arg_num() & tokenize_cmd() are already
shared by the hostapd_cli & wpa_cli commands by including the cli.h header.
So follow the same for wlantest_cli and remove the duplicate function defs.

Signed-off-by: Gokul Sivakumar <gokulkumar792@xxxxxxxxx>
---
 wlantest/Makefile       |  1 +
 wlantest/wlantest_cli.c | 50 +----------------------------------------
 2 files changed, 2 insertions(+), 49 deletions(-)

diff --git a/wlantest/Makefile b/wlantest/Makefile
index 0045020d4..1eba3cec9 100644
--- a/wlantest/Makefile
+++ b/wlantest/Makefile
@@ -64,6 +64,7 @@ TOBJS += gcmp.o
 
 
 OBJS_cli = wlantest_cli.o
+OBJS_cli += ../src/common/cli.o
 
 _OBJS_VAR := OBJS
 include ../src/objs.mk
diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index 7e0f8444a..eb7bc59ba 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -13,27 +13,11 @@
 #include "utils/eloop.h"
 #include "utils/edit.h"
 #include "wlantest_ctrl.h"
+#include "common/cli.h"
 
 static void print_help(FILE *stream, const char *cmd);
 static char ** wlantest_cli_cmd_list(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 get_prev_arg_pos(const char *str, int pos)
 {
@@ -1730,38 +1714,6 @@ struct wlantest_cli {
 };
 
 
-#define max_args 10
-
-static int tokenize_cmd(char *cmd, char *argv[])
-{
-	char *pos;
-	int argc = 0;
-
-	pos = cmd;
-	for (;;) {
-		while (*pos == ' ')
-			pos++;
-		if (*pos == '\0')
-			break;
-		argv[argc] = pos;
-		argc++;
-		if (argc == max_args)
-			break;
-		if (*pos == '"') {
-			char *pos2 = os_strrchr(pos, '"');
-			if (pos2)
-				pos = pos2 + 1;
-		}
-		while (*pos != '\0' && *pos != ' ')
-			pos++;
-		if (*pos == ' ')
-			*pos++ = '\0';
-	}
-
-	return argc;
-}
-
-
 static void wlantest_cli_edit_cmd_cb(void *ctx, char *cmd)
 {
 	struct wlantest_cli *cli = ctx;
-- 
2.25.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux