1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdio.h>
5 
6 /* The *_extension_release flavours will look for /usr/lib/extension-release/extension-release.NAME
7  * in accordance with the OS extension specification, rather than for /usr/lib/ or /etc/os-release. */
8 
9 bool image_name_is_valid(const char *s) _pure_;
10 
11 int path_is_extension_tree(const char *path, const char *extension);
path_is_os_tree(const char * path)12 static inline int path_is_os_tree(const char *path) {
13         return path_is_extension_tree(path, NULL);
14 }
15 
16 int open_extension_release(const char *root, const char *extension, char **ret_path, int *ret_fd);
open_os_release(const char * root,char ** ret_path,int * ret_fd)17 static inline int open_os_release(const char *root, char **ret_path, int *ret_fd) {
18         return open_extension_release(root, NULL, ret_path, ret_fd);
19 }
20 
21 int fopen_extension_release(const char *root, const char *extension, char **ret_path, FILE **ret_file);
fopen_os_release(const char * root,char ** ret_path,FILE ** ret_file)22 static inline int fopen_os_release(const char *root, char **ret_path, FILE **ret_file) {
23         return fopen_extension_release(root, NULL, ret_path, ret_file);
24 }
25 
26 int _parse_extension_release(const char *root, const char *extension, ...) _sentinel_;
27 int _parse_os_release(const char *root, ...) _sentinel_;
28 #define parse_extension_release(root, extension, ...) _parse_extension_release(root, extension, __VA_ARGS__, NULL)
29 #define parse_os_release(root, ...) _parse_os_release(root, __VA_ARGS__, NULL)
30 
31 int load_extension_release_pairs(const char *root, const char *extension, char ***ret);
32 int load_os_release_pairs(const char *root, char ***ret);
33 int load_os_release_pairs_with_prefix(const char *root, const char *prefix, char ***ret);
34