summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unformat.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-07-31 20:07:31 +0200
committerDamjan Marion <damarion@cisco.com>2023-07-31 20:10:57 +0200
commitf566524a210dcf55a667e54bdaae2a833a9b13a5 (patch)
tree507da518e5f23499457692cc778332c79bbf9443 /src/vppinfra/unformat.c
parent83ca6e66d090b91c84637d7a5ed6a91fa41f8359 (diff)
vppinfra: add unformat_c_string_array
Type: improvement Change-Id: Iea5ecca5d4cbc6c7aea69104830afcfe78c708ee Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/unformat.c')
-rw-r--r--src/vppinfra/unformat.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vppinfra/unformat.c b/src/vppinfra/unformat.c
index e8e5c28ea8c..a07f4e06df5 100644
--- a/src/vppinfra/unformat.c
+++ b/src/vppinfra/unformat.c
@@ -1086,6 +1086,30 @@ unformat_data_size (unformat_input_t * input, va_list * args)
return 1;
}
+__clib_export uword
+unformat_c_string_array (unformat_input_t *input, va_list *va)
+{
+ char *str = va_arg (*va, char *);
+ u32 array_len = va_arg (*va, u32);
+ uword c, rv = 0;
+ u8 *s = 0;
+
+ if (unformat (input, "%v", &s) == 0)
+ return 0;
+
+ c = vec_len (s);
+
+ if (c > 0 && c < array_len)
+ {
+ clib_memcpy (str, s, c);
+ str[c] = 0;
+ rv = 1;
+ }
+
+ vec_free (s);
+ return rv;
+}
+
#endif /* CLIB_UNIX */