]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fileio: add parse_env_filev() that is like parse_env_file() but takes a va_list
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Mar 2018 17:20:47 +0000 (19:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 May 2018 15:01:57 +0000 (17:01 +0200)
src/basic/fileio.c
src/basic/fileio.h

index 375d6fd5b34da670e7f4d7ca0828f8ee1e8cb3fd..1f984d5295f2d2f399a2ae2af9697e4f78844aff 100644 (file)
@@ -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(
index 6be261ba0ba80df3b72aff6a4459d2b0d35aa0eb..addd9bade45b63a7feddcd978f795ed48b49e954 100644 (file)
@@ -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);