From: Yu Watanabe Date: Sat, 8 Apr 2023 08:48:04 +0000 (+0900) Subject: env-file: introduce parse_env_file_fdv() X-Git-Tag: v254-rc1~771 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06692fdb5bf3d5e53f3f4847e1f8da18180075cb;p=thirdparty%2Fsystemd.git env-file: introduce parse_env_file_fdv() --- diff --git a/src/basic/env-file.c b/src/basic/env-file.c index 01ed443d5f4..7b3e209ddca 100644 --- a/src/basic/env-file.c +++ b/src/basic/env-file.c @@ -359,6 +359,23 @@ int parse_env_filev( return r; } +int parse_env_file_fdv(int fd, const char *fname, va_list ap) { + _cleanup_fclose_ FILE *f = NULL; + va_list aq; + int r; + + assert(fd >= 0); + + r = fdopen_independent(fd, "re", &f); + if (r < 0) + return r; + + va_copy(aq, ap); + r = parse_env_file_internal(f, fname, parse_env_file_push, &aq); + va_end(aq); + return r; +} + int parse_env_file_sentinel( FILE *f, const char *fname, @@ -381,18 +398,13 @@ int parse_env_file_fd_sentinel( const char *fname, /* only used for logging */ ...) { - _cleanup_fclose_ FILE *f = NULL; va_list ap; int r; assert(fd >= 0); - r = fdopen_independent(fd, "re", &f); - if (r < 0) - return r; - va_start(ap, fname); - r = parse_env_filev(f, fname, ap); + r = parse_env_file_fdv(fd, fname, ap); va_end(ap); return r; diff --git a/src/basic/env-file.h b/src/basic/env-file.h index fa22d2209c6..2465eeddf4d 100644 --- a/src/basic/env-file.h +++ b/src/basic/env-file.h @@ -8,6 +8,7 @@ #include "macro.h" int parse_env_filev(FILE *f, const char *fname, va_list ap); +int parse_env_file_fdv(int fd, const char *fname, va_list ap); int parse_env_file_sentinel(FILE *f, const char *fname, ...) _sentinel_; #define parse_env_file(f, fname, ...) parse_env_file_sentinel(f, fname, __VA_ARGS__, NULL) int parse_env_file_fd_sentinel(int fd, const char *fname, ...) _sentinel_;