aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_kvargs/rte_kvargs.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_kvargs/rte_kvargs.h')
-rw-r--r--lib/librte_kvargs/rte_kvargs.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h
index 51b8120b..fc041956 100644
--- a/lib/librte_kvargs/rte_kvargs.h
+++ b/lib/librte_kvargs/rte_kvargs.h
@@ -25,6 +25,8 @@
extern "C" {
#endif
+#include <rte_compat.h>
+
/** Maximum number of key/value associations */
#define RTE_KVARGS_MAX 32
@@ -72,6 +74,36 @@ struct rte_kvargs *rte_kvargs_parse(const char *args,
const char *const valid_keys[]);
/**
+ * Allocate a rte_kvargs and store key/value associations from a string.
+ * This version will consider any byte from valid_ends as a possible
+ * terminating character, and will not parse beyond any of their occurrence.
+ *
+ * The function allocates and fills an rte_kvargs structure from a given
+ * string whose format is key1=value1,key2=value2,...
+ *
+ * The structure can be freed with rte_kvargs_free().
+ *
+ * @param args
+ * The input string containing the key/value associations
+ *
+ * @param valid_keys
+ * A list of valid keys (table of const char *, the last must be NULL).
+ * This argument is ignored if NULL
+ *
+ * @param valid_ends
+ * Acceptable terminating characters.
+ * If NULL, the behavior is the same as ``rte_kvargs_parse``.
+ *
+ * @return
+ * - A pointer to an allocated rte_kvargs structure on success
+ * - NULL on error
+ */
+__rte_experimental
+struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
+ const char *const valid_keys[],
+ const char *valid_ends);
+
+/**
* Free a rte_kvargs structure
*
* Free a rte_kvargs structure previously allocated with
@@ -121,6 +153,32 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
unsigned rte_kvargs_count(const struct rte_kvargs *kvlist,
const char *key_match);
+/**
+ * Generic kvarg handler for string comparison.
+ *
+ * This function can be used for a generic string comparison processing
+ * on a list of kvargs.
+ *
+ * @param key
+ * kvarg pair key.
+ *
+ * @param value
+ * kvarg pair value.
+ *
+ * @param opaque
+ * Opaque pointer to a string.
+ *
+ * @return
+ * 0 if the strings match.
+ * !0 otherwise or on error.
+ *
+ * Unless strcmp, comparison ordering is not kept.
+ * In order for rte_kvargs_process to stop processing on match error,
+ * a negative value is returned even if strcmp had returned a positive one.
+ */
+__rte_experimental
+int rte_kvargs_strcmp(const char *key, const char *value, void *opaque);
+
#ifdef __cplusplus
}
#endif