strv: add helper to find value in key/value pairs from list of keys
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-util.h"
|
||||
#include "escape.h"
|
||||
#include "extract-word.h"
|
||||
#include "fileio.h"
|
||||
@@ -63,6 +64,16 @@ char* strv_find_startswith(char * const *l, const char *name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* strv_find_first_field(char * const *needles, char * const *haystack) {
|
||||
STRV_FOREACH(k, needles) {
|
||||
char *value = strv_env_pairs_get((char **)haystack, *k);
|
||||
if (value)
|
||||
return value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char** strv_free(char **l) {
|
||||
STRV_FOREACH(k, l)
|
||||
free(*k);
|
||||
|
||||
Reference in New Issue
Block a user