mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
fileio: add parse_env_filev() that is like parse_env_file() but takes a va_list
This commit is contained in:
parent
1a5a177eaf
commit
080dfda85a
@ -676,22 +676,41 @@ static int parse_env_file_push(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_env_file(
|
||||
int parse_env_filev(
|
||||
FILE *f,
|
||||
const char *fname,
|
||||
const char *newline, ...) {
|
||||
const char *newline,
|
||||
va_list ap) {
|
||||
|
||||
va_list ap;
|
||||
int r, n_pushed = 0;
|
||||
va_list aq;
|
||||
|
||||
if (!newline)
|
||||
newline = NEWLINE;
|
||||
|
||||
va_copy(aq, ap);
|
||||
r = parse_env_file_internal(f, fname, newline, parse_env_file_push, &aq, &n_pushed);
|
||||
va_end(aq);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return n_pushed;
|
||||
}
|
||||
|
||||
int parse_env_file(
|
||||
FILE *f,
|
||||
const char *fname,
|
||||
const char *newline,
|
||||
...) {
|
||||
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
va_start(ap, newline);
|
||||
r = parse_env_file_internal(f, fname, newline, parse_env_file_push, &ap, &n_pushed);
|
||||
r = parse_env_filev(f, fname, newline, ap);
|
||||
va_end(ap);
|
||||
|
||||
return r < 0 ? r : n_pushed;
|
||||
return r;
|
||||
}
|
||||
|
||||
static int load_env_file_push(
|
||||
|
@ -45,6 +45,7 @@ int read_full_stream(FILE *f, char **contents, size_t *size);
|
||||
|
||||
int verify_file(const char *fn, const char *blob, bool accept_extra_nl);
|
||||
|
||||
int parse_env_filev(FILE *f, const char *fname, const char *separator, va_list ap);
|
||||
int parse_env_file(FILE *f, const char *fname, const char *separator, ...) _sentinel_;
|
||||
int load_env_file(FILE *f, const char *fname, const char *separator, char ***l);
|
||||
int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l);
|
||||
|
Loading…
x
Reference in New Issue
Block a user