diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-01-08 18:46:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-12-02 09:47:00 +0100 |
commit | f325aaf3417590a29d1c362a118532ea11fb020d (patch) | |
tree | c355ff5d209b26007128079cb6011a0947538c8b /src/shared/json.h | |
parent | 83bc6cb792330760efd02f1c9df80d3bcfae1453 (diff) | |
download | systemd-f325aaf3417590a29d1c362a118532ea11fb020d.tar.gz |
json: add json_parse_file_at() helper
This is an "at" function, similar to json_parse_file().
Diffstat (limited to 'src/shared/json.h')
-rw-r--r-- | src/shared/json.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/shared/json.h b/src/shared/json.h index 8e589a0b84..dd1aff450a 100644 --- a/src/shared/json.h +++ b/src/shared/json.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once +#include <fcntl.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -175,7 +176,11 @@ int json_variant_set_field(JsonVariant **v, const char *field, JsonVariant *valu int json_parse(const char *string, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column); int json_parse_continue(const char **p, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column); -int json_parse_file(FILE *f, const char *path, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column); +int json_parse_file_at(FILE *f, int dir_fd, const char *path, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column); + +static inline int json_parse_file(FILE *f, const char *path, JsonVariant **ret, unsigned *ret_line, unsigned *ret_column) { + return json_parse_file_at(f, AT_FDCWD, path, ret, ret_line, ret_column); +} enum { _JSON_BUILD_STRING, |