]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/fdset.h
journal: Add journal.storage credential
[thirdparty/systemd.git] / src / shared / fdset.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
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
10typedef struct FDSet FDSet;
11
12FDSet* fdset_new(void);
a354329f 13FDSet* fdset_free(FDSet *s);
a16e1123
LP
14
15int fdset_put(FDSet *s, int fd);
e829f28c 16int fdset_consume(FDSet *s, int fd);
a16e1123
LP
17int fdset_put_dup(FDSet *s, int fd);
18
19bool fdset_contains(FDSet *s, int fd);
20int fdset_remove(FDSet *s, int fd);
21
da6053d0 22int fdset_new_array(FDSet **ret, const int *fds, size_t n_fds);
a3dff21a 23int fdset_new_fill(int filter_cloexec, FDSet **ret);
a354329f 24int fdset_new_listen_fds(FDSet **ret, bool unset);
a16e1123
LP
25
26int fdset_cloexec(FDSet *fds, bool b);
e83c7163 27
bdcad22e
LP
28int fdset_to_array(FDSet *fds, int **ret);
29
e83c7163
LP
30int fdset_close_others(FDSet *fds);
31
32unsigned fdset_size(FDSet *fds);
a354329f 33bool fdset_isempty(FDSet *fds);
e83c7163
LP
34
35int fdset_iterate(FDSet *s, Iterator *i);
36
a354329f
LP
37int fdset_steal_first(FDSet *fds);
38
e4077ff6
LP
39void fdset_close(FDSet *fds);
40
90e74a66
ZJS
41#define _FDSET_FOREACH(fd, fds, i) \
42 for (Iterator i = ITERATOR_FIRST; ((fd) = fdset_iterate((fds), &i)) >= 0; )
43#define FDSET_FOREACH(fd, fds) \
44 _FDSET_FOREACH(fd, fds, UNIQ_T(i, UNIQ))
51d122af 45
14bf2c9d 46DEFINE_TRIVIAL_CLEANUP_FUNC(FDSet*, fdset_free);
51d122af 47#define _cleanup_fdset_free_ _cleanup_(fdset_freep)