]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/BoolOps.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / acl / BoolOps.h
1 /*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_ACL_LOGIC_H
10 #define SQUID_ACL_LOGIC_H
11
12 #include "acl/InnerNode.h"
13
14 /* ACLs defined here are used internally to construct an ACL expression tree.
15 * They cannot be specified directly in squid.conf because squid.conf ACLs are
16 * more complex than (and are implemented using) these operator-like classes.*/
17
18 namespace Acl
19 {
20
21 /// Implements the "not" or "!" operator.
22 class NotNode: public InnerNode
23 {
24 MEMPROXY_CLASS(NotNode);
25
26 public:
27 explicit NotNode(ACL *acl);
28
29 private:
30 /* ACL API */
31 char const *typeString() const override;
32 void parse() override;
33 SBufList dump() const override;
34
35 /* Acl::InnerNode API */
36 int doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const override;
37 };
38
39 /// An inner ACL expression tree node representing a boolean conjunction (AND)
40 /// operator applied to a list of child tree nodes.
41 /// For example, conditions expressed on a single http_access line are ANDed.
42 class AndNode: public InnerNode
43 {
44 MEMPROXY_CLASS(AndNode);
45
46 public:
47 /* ACL API */
48 char const *typeString() const override;
49 void parse() override;
50
51 private:
52 int doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const override;
53 };
54
55 /// An inner ACL expression tree node representing a boolean disjuction (OR)
56 /// operator applied to a list of child tree nodes.
57 /// For example, conditions expressed by multiple http_access lines are ORed.
58 class OrNode: public InnerNode
59 {
60 MEMPROXY_CLASS(OrNode);
61
62 public:
63 /// whether the given rule should be excluded from matching tests based
64 /// on its action
65 virtual bool bannedAction(ACLChecklist *, Nodes::const_iterator) const;
66
67 /* ACL API */
68 char const *typeString() const override;
69 void parse() override;
70
71 protected:
72 mutable Nodes::const_iterator lastMatch_;
73
74 private:
75 int doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const override;
76 };
77
78 } // namespace Acl
79
80 #endif /* SQUID_ACL_LOGIC_H */
81