projects
/
mech_eap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
cli: Share a common get_cmd_arg_num() implementation
[mech_eap.git]
/
src
/
common
/
cli.c
diff --git
a/src/common/cli.c
b/src/common/cli.c
index
24f465c
..
6e00188
100644
(file)
--- a/
src/common/cli.c
+++ b/
src/common/cli.c
@@
-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;
+}