]> Sergey Matveev's repositories - bfs.git/blob - src/eval.h
Skip mtab
[bfs.git] / src / eval.h
1 // Copyright © Tavian Barnes <tavianator@tavianator.com>
2 // SPDX-License-Identifier: 0BSD
3
4 /**
5  * The evaluation functions that implement primary expressions like -name,
6  * -print, etc.
7  */
8
9 #ifndef BFS_EVAL_H
10 #define BFS_EVAL_H
11
12 #include "config.h"
13
14 struct bfs_ctx;
15 struct bfs_expr;
16
17 /**
18  * Ephemeral state for evaluating an expression.
19  */
20 struct bfs_eval;
21
22 /**
23  * Expression evaluation function.
24  *
25  * @param expr
26  *         The current expression.
27  * @param state
28  *         The current evaluation state.
29  * @return
30  *         The result of the test.
31  */
32 typedef bool bfs_eval_fn(const struct bfs_expr *expr, struct bfs_eval *state);
33
34 /**
35  * Evaluate the command line.
36  *
37  * @param ctx
38  *         The bfs context to evaluate.
39  * @return
40  *         EXIT_SUCCESS on success, otherwise on failure.
41  */
42 int bfs_eval(const struct bfs_ctx *ctx);
43
44 // Predicate evaluation functions
45
46 bool eval_true(const struct bfs_expr *expr, struct bfs_eval *state);
47 bool eval_false(const struct bfs_expr *expr, struct bfs_eval *state);
48
49 bool eval_access(const struct bfs_expr *expr, struct bfs_eval *state);
50 bool eval_acl(const struct bfs_expr *expr, struct bfs_eval *state);
51 bool eval_capable(const struct bfs_expr *expr, struct bfs_eval *state);
52 bool eval_perm(const struct bfs_expr *expr, struct bfs_eval *state);
53 bool eval_xattr(const struct bfs_expr *expr, struct bfs_eval *state);
54 bool eval_xattrname(const struct bfs_expr *expr, struct bfs_eval *state);
55
56 bool eval_newer(const struct bfs_expr *expr, struct bfs_eval *state);
57 bool eval_time(const struct bfs_expr *expr, struct bfs_eval *state);
58 bool eval_used(const struct bfs_expr *expr, struct bfs_eval *state);
59
60 bool eval_gid(const struct bfs_expr *expr, struct bfs_eval *state);
61 bool eval_uid(const struct bfs_expr *expr, struct bfs_eval *state);
62 bool eval_nogroup(const struct bfs_expr *expr, struct bfs_eval *state);
63 bool eval_nouser(const struct bfs_expr *expr, struct bfs_eval *state);
64
65 bool eval_depth(const struct bfs_expr *expr, struct bfs_eval *state);
66 bool eval_empty(const struct bfs_expr *expr, struct bfs_eval *state);
67 bool eval_flags(const struct bfs_expr *expr, struct bfs_eval *state);
68 bool eval_fstype(const struct bfs_expr *expr, struct bfs_eval *state);
69 bool eval_hidden(const struct bfs_expr *expr, struct bfs_eval *state);
70 bool eval_inum(const struct bfs_expr *expr, struct bfs_eval *state);
71 bool eval_links(const struct bfs_expr *expr, struct bfs_eval *state);
72 bool eval_samefile(const struct bfs_expr *expr, struct bfs_eval *state);
73 bool eval_size(const struct bfs_expr *expr, struct bfs_eval *state);
74 bool eval_sparse(const struct bfs_expr *expr, struct bfs_eval *state);
75 bool eval_type(const struct bfs_expr *expr, struct bfs_eval *state);
76 bool eval_xtype(const struct bfs_expr *expr, struct bfs_eval *state);
77
78 bool eval_lname(const struct bfs_expr *expr, struct bfs_eval *state);
79 bool eval_name(const struct bfs_expr *expr, struct bfs_eval *state);
80 bool eval_path(const struct bfs_expr *expr, struct bfs_eval *state);
81 bool eval_regex(const struct bfs_expr *expr, struct bfs_eval *state);
82
83 bool eval_delete(const struct bfs_expr *expr, struct bfs_eval *state);
84 bool eval_exec(const struct bfs_expr *expr, struct bfs_eval *state);
85 bool eval_exit(const struct bfs_expr *expr, struct bfs_eval *state);
86 bool eval_fls(const struct bfs_expr *expr, struct bfs_eval *state);
87 bool eval_fprint(const struct bfs_expr *expr, struct bfs_eval *state);
88 bool eval_fprint0(const struct bfs_expr *expr, struct bfs_eval *state);
89 bool eval_fprintf(const struct bfs_expr *expr, struct bfs_eval *state);
90 bool eval_fprintx(const struct bfs_expr *expr, struct bfs_eval *state);
91 bool eval_prune(const struct bfs_expr *expr, struct bfs_eval *state);
92 bool eval_quit(const struct bfs_expr *expr, struct bfs_eval *state);
93
94 // Operator evaluation functions
95 bool eval_not(const struct bfs_expr *expr, struct bfs_eval *state);
96 bool eval_and(const struct bfs_expr *expr, struct bfs_eval *state);
97 bool eval_or(const struct bfs_expr *expr, struct bfs_eval *state);
98 bool eval_comma(const struct bfs_expr *expr, struct bfs_eval *state);
99
100 #endif // BFS_EVAL_H