mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
os-util: merge parse_{extension,os}_release()
This commit is contained in:
parent
7ef43c78df
commit
f4a1d32c82
|
@ -242,40 +242,25 @@ int open_extension_release(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int parse_release_internal(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, va_list ap) {
|
||||
int parse_extension_release_sentinel(
|
||||
const char *root,
|
||||
ImageClass image_class,
|
||||
bool relax_extension_release_check,
|
||||
const char *extension,
|
||||
...) {
|
||||
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
r = open_extension_release(root, image_class, extension, relax_extension_release_check, &p, &fd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return parse_env_file_fdv(fd, p, ap);
|
||||
}
|
||||
|
||||
int _parse_extension_release(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) {
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
assert(image_class >= 0);
|
||||
assert(image_class < _IMAGE_CLASS_MAX);
|
||||
|
||||
va_start(ap, extension);
|
||||
r = parse_release_internal(root, image_class, relax_extension_release_check, extension, ap);
|
||||
r = parse_env_file_fdv(fd, p, ap);
|
||||
va_end(ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int _parse_os_release(const char *root, ...) {
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
va_start(ap, root);
|
||||
r = parse_release_internal(root, _IMAGE_CLASS_INVALID, /* relax_extension_release_check= */ false, NULL, ap);
|
||||
va_end(ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,11 @@ static inline int path_is_os_tree(const char *path) {
|
|||
int open_extension_release(const char *root, ImageClass image_class, const char *extension, bool relax_extension_release_check, char **ret_path, int *ret_fd);
|
||||
int open_os_release(const char *root, char **ret_path, int *ret_fd);
|
||||
|
||||
int _parse_extension_release(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) _sentinel_;
|
||||
int _parse_os_release(const char *root, ...) _sentinel_;
|
||||
#define parse_extension_release(root, image_class, extension, relax_extension_release_check, ...) _parse_extension_release(root, image_class, relax_extension_release_check, extension, __VA_ARGS__, NULL)
|
||||
#define parse_os_release(root, ...) _parse_os_release(root, __VA_ARGS__, NULL)
|
||||
int parse_extension_release_sentinel(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) _sentinel_;
|
||||
#define parse_extension_release(root, image_class, extension, relax_extension_release_check, ...) \
|
||||
parse_extension_release_sentinel(root, image_class, relax_extension_release_check, extension, __VA_ARGS__, NULL)
|
||||
#define parse_os_release(root, ...) \
|
||||
parse_extension_release_sentinel(root, _IMAGE_CLASS_INVALID, false, NULL, __VA_ARGS__, NULL)
|
||||
|
||||
int load_extension_release_pairs(const char *root, ImageClass image_class, const char *extension, bool relax_extension_release_check, char ***ret);
|
||||
static inline int load_os_release_pairs(const char *root, char ***ret) {
|
||||
|
|
Loading…
Reference in a new issue