1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 #include <sys/types.h>
6 
7 typedef struct UidRange {
8         uid_t start, nr;
9 } UidRange;
10 
11 int uid_range_add(UidRange **p, size_t *n, uid_t start, uid_t nr);
12 int uid_range_add_str(UidRange **p, size_t *n, const char *s);
13 
14 int uid_range_next_lower(const UidRange *p, size_t n, uid_t *uid);
15 bool uid_range_covers(const UidRange *p, size_t n, uid_t start, uid_t nr);
16 
uid_range_contains(const UidRange * p,size_t n,uid_t uid)17 static inline bool uid_range_contains(const UidRange *p, size_t n, uid_t uid) {
18         return uid_range_covers(p, n, uid, 1);
19 }
20 
21 int uid_range_load_userns(UidRange **p, size_t *n, const char *path);
22