]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
a16e1123 | 3 | |
11c3a366 TA |
4 | #include <stdbool.h> |
5 | ||
11c3a366 TA |
6 | #include "hashmap.h" |
7 | #include "macro.h" | |
93cc7779 | 8 | #include "set.h" |
e83c7163 | 9 | |
a16e1123 LP |
10 | typedef struct FDSet FDSet; |
11 | ||
12 | FDSet* fdset_new(void); | |
a354329f | 13 | FDSet* fdset_free(FDSet *s); |
a16e1123 LP |
14 | |
15 | int fdset_put(FDSet *s, int fd); | |
16 | int fdset_put_dup(FDSet *s, int fd); | |
17 | ||
18 | bool fdset_contains(FDSet *s, int fd); | |
19 | int fdset_remove(FDSet *s, int fd); | |
20 | ||
da6053d0 | 21 | int fdset_new_array(FDSet **ret, const int *fds, size_t n_fds); |
a354329f LP |
22 | int fdset_new_fill(FDSet **ret); |
23 | int fdset_new_listen_fds(FDSet **ret, bool unset); | |
a16e1123 LP |
24 | |
25 | int fdset_cloexec(FDSet *fds, bool b); | |
e83c7163 LP |
26 | |
27 | int fdset_close_others(FDSet *fds); | |
28 | ||
29 | unsigned fdset_size(FDSet *fds); | |
a354329f | 30 | bool fdset_isempty(FDSet *fds); |
e83c7163 LP |
31 | |
32 | int fdset_iterate(FDSet *s, Iterator *i); | |
33 | ||
a354329f LP |
34 | int fdset_steal_first(FDSet *fds); |
35 | ||
e83c7163 LP |
36 | #define FDSET_FOREACH(fd, fds, i) \ |
37 | for ((i) = ITERATOR_FIRST, (fd) = fdset_iterate((fds), &(i)); (fd) >= 0; (fd) = fdset_iterate((fds), &(i))) | |
51d122af | 38 | |
14bf2c9d | 39 | DEFINE_TRIVIAL_CLEANUP_FUNC(FDSet*, fdset_free); |
51d122af | 40 | #define _cleanup_fdset_free_ _cleanup_(fdset_freep) |