summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/format.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-08-06 20:39:38 +0200
committerFlorin Coras <florin.coras@gmail.com>2023-08-07 17:33:09 +0000
commit8d0c0c68215a2972053ba7fd8fa0f82aa14f8624 (patch)
tree035f14012dfd939890cf360898be6d4e71021504 /src/vppinfra/format.h
parent696db20e332fcbecaaef9c5505cc2e132bfaa9e2 (diff)
vppinfra: add unformat_init_path
More conveninet way to unformat file by providing filesystem path. Takes format string for easier constuction of path... Type: improvement Change-Id: I433204fa20dc98e2b11c53914883d047a7fc62c6 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/format.h')
-rw-r--r--src/vppinfra/format.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vppinfra/format.h b/src/vppinfra/format.h
index 7254031a0ea..cf5e1f6dcce 100644
--- a/src/vppinfra/format.h
+++ b/src/vppinfra/format.h
@@ -133,8 +133,11 @@ typedef struct _unformat_input_t
(and argument). */
uword (*fill_buffer) (struct _unformat_input_t * i);
- /* Return values for fill buffer function which indicate whether not
- input has been exhausted. */
+ /* User's function to be called on input_free */
+ void (*free) (struct _unformat_input_t *i);
+
+ /* Return values for fill buffer function which indicate whether not
+ input has been exhausted. */
#define UNFORMAT_END_OF_INPUT (~0)
#define UNFORMAT_MORE_INPUT 0
@@ -155,6 +158,8 @@ unformat_init (unformat_input_t * i,
always_inline void
unformat_free (unformat_input_t * i)
{
+ if (i->free)
+ i->free (i);
vec_free (i->buffer);
vec_free (i->buffer_marks);
clib_memset (i, 0, sizeof (i[0]));
@@ -336,6 +341,9 @@ u8 *format_uword_bitmap (u8 *s, va_list *va);
/* Setup input from Unix file. */
void unformat_init_clib_file (unformat_input_t * input, int file_descriptor);
+/* Setup input from flesystem path. */
+uword unformat_init_file (unformat_input_t *input, char *fmt, ...);
+
/* Take input from Unix environment variable; returns
1 if variable exists zero otherwise. */
uword unformat_init_unix_env (unformat_input_t * input, char *var);