Merge pull request #26941 from bluca/portable_version
portable: introduce SYSEXT_ fields to identify sysexts, and include more metadata in log messages via LogExtraFields=
This commit is contained in:
@@ -478,6 +478,7 @@ int load_env_file_pairs(FILE *f, const char *fname, char ***ret) {
|
||||
int r;
|
||||
|
||||
assert(f || fname);
|
||||
assert(ret);
|
||||
|
||||
r = parse_env_file_internal(f, fname, load_env_file_push_pairs, &m);
|
||||
if (r < 0)
|
||||
@@ -487,6 +488,19 @@ int load_env_file_pairs(FILE *f, const char *fname, char ***ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_env_file_pairs_fd(int fd, const char *fname, char ***ret) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
r = fdopen_independent(fd, "re", &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return load_env_file_pairs(f, fname, ret);
|
||||
}
|
||||
|
||||
static int merge_env_file_push(
|
||||
const char *filename, unsigned line,
|
||||
const char *key, char *value,
|
||||
|
||||
@@ -14,6 +14,7 @@ int parse_env_file_fd_sentinel(int fd, const char *fname, ...) _sentinel_;
|
||||
#define parse_env_file_fd(fd, fname, ...) parse_env_file_fd_sentinel(fd, fname, __VA_ARGS__, NULL)
|
||||
int load_env_file(FILE *f, const char *fname, char ***ret);
|
||||
int load_env_file_pairs(FILE *f, const char *fname, char ***ret);
|
||||
int load_env_file_pairs_fd(int fd, const char *fname, char ***ret);
|
||||
|
||||
int merge_env_file(char ***env, FILE *f, const char *fname);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -17,6 +17,9 @@ char* strv_find(char * const *l, const char *name) _pure_;
|
||||
char* strv_find_case(char * const *l, const char *name) _pure_;
|
||||
char* strv_find_prefix(char * const *l, const char *name) _pure_;
|
||||
char* strv_find_startswith(char * const *l, const char *name) _pure_;
|
||||
/* Given two vectors, the first a list of keys and the second a list of key-value pairs, returns the value
|
||||
* of the first key from the first vector that is found in the second vector. */
|
||||
char* strv_find_first_field(char * const *needles, char * const *haystack) _pure_;
|
||||
|
||||
#define strv_contains(l, s) (!!strv_find((l), (s)))
|
||||
#define strv_contains_case(l, s) (!!strv_find_case((l), (s)))
|
||||
|
||||
Reference in New Issue
Block a user