doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_kvargs / rte_kvargs.c
index ffae891..38e9d5c 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <stdbool.h>
 
+#include <rte_os_shim.h>
 #include <rte_string_fns.h>
 
 #include "rte_kvargs.h"
@@ -203,6 +204,21 @@ rte_kvargs_free(struct rte_kvargs *kvlist)
        free(kvlist);
 }
 
+/* Lookup a value in an rte_kvargs list by its key. */
+const char *
+rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+{
+       unsigned int i;
+
+       if (kvlist == NULL || key == NULL)
+               return NULL;
+       for (i = 0; i < kvlist->count; ++i) {
+               if (strcmp(kvlist->pairs[i].key, key) == 0)
+                       return kvlist->pairs[i].value;
+       }
+       return NULL;
+}
+
 /*
  * Parse the arguments "key=value,key=value,..." string and return
  * an allocated structure that contains a key/value list. Also