po: Update German man pages translation
[dpkg.git] / lib / dpkg / treewalk.h
blob8c14d80180bcc75f0e623ef8b93c8d489bc46b3f
1 /*
2 * libdpkg - Debian packaging suite library routines
3 * treewalk.h - directory tree walk support
5 * Copyright © 2013-2015 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 #ifndef LIBDPKG_TREEWALK_H
22 #define LIBDPKG_TREEWALK_H
24 #include <dpkg/macros.h>
26 #include <sys/stat.h>
27 #include <sys/types.h>
29 #include <stdbool.h>
31 DPKG_BEGIN_DECLS
33 /**
34 * @defgroup treewalk Directory tree walking
35 * @ingroup dpkg-internal
36 * @{
39 enum DPKG_ATTR_ENUM_FLAGS treewalk_options {
40 TREEWALK_NONE = 0,
41 TREEWALK_FORCE_STAT = DPKG_BIT(0),
42 TREEWALK_FOLLOW_LINKS = DPKG_BIT(1),
45 struct treenode;
47 typedef int treenode_visit_func(struct treenode *node);
48 typedef bool treenode_skip_func(struct treenode *node);
49 typedef int treenode_sort_func(struct treenode *node);
51 struct treewalk_funcs {
52 treenode_visit_func *visit;
53 treenode_sort_func *sort;
54 treenode_skip_func *skip;
57 #if __STDC_VERSION__ > 201710L
58 #define TREEWALK_OBJECT (struct treewalk_funcs){ }
59 #else
60 #define TREEWALK_OBJECT (struct treewalk_funcs){ 0 }
61 #endif
63 struct treeroot *
64 treewalk_open(const char *rootdir, enum treewalk_options options,
65 const struct treewalk_funcs *funcs);
66 struct treenode *
67 treewalk_node(struct treeroot *tree);
68 struct treenode *
69 treewalk_next(struct treeroot *tree);
70 void
71 treewalk_close(struct treeroot *tree);
73 int
74 treewalk(const char *rootdir, enum treewalk_options options,
75 struct treewalk_funcs *funcs);
77 struct treenode *
78 treenode_get_parent(struct treenode *node);
79 const char *
80 treenode_get_name(struct treenode *node);
81 const char *
82 treenode_get_pathname(struct treenode *node);
83 const char *
84 treenode_get_virtname(struct treenode *node);
85 mode_t
86 treenode_get_mode(struct treenode *node);
87 struct stat *
88 treenode_get_stat(struct treenode *node);
90 /** @} */
92 DPKG_END_DECLS
94 #endif /* LIBDPKG_TREEWALK_H */