]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Tree.cc
5 CBDATA_NAMESPACED_CLASS_INIT(Acl
, Tree
);
8 Acl::Tree::winningAction() const
10 return actionAt(lastMatch_
- nodes
.begin());
14 Acl::Tree::lastAction() const
18 return actions
.back();
21 /// computes action that corresponds to the position of the matched rule
23 Acl::Tree::actionAt(const Nodes::size_type pos
) const
25 assert(0 <= pos
&& pos
< nodes
.size());
27 assert(actions
.size() == nodes
.size());
30 // default for matched rules in trees without actions
31 return ACCESS_ALLOWED
;
35 Acl::Tree::add(ACL
*rule
, const allow_t
&action
)
37 // either all rules have actions or none
38 assert(nodes
.size() == actions
.size());
40 actions
.push_back(action
);
44 Acl::Tree::add(ACL
*rule
)
46 // either all rules have actions or none
47 assert(actions
.empty());
52 Acl::Tree::treeDump(const char *prefix
, const ActionToString
&convert
) const
54 wordlist
*text
= NULL
;
55 Actions::const_iterator action
= actions
.begin();
56 typedef Nodes::const_iterator NCI
;
57 for (NCI node
= nodes
.begin(); node
!= nodes
.end(); ++node
) {
59 wordlistAdd(&text
, prefix
);
61 if (action
!= actions
.end()) {
62 const char *act
= convert
? convert
[action
->kind
] :
63 (*action
== ACCESS_ALLOWED
? "allow" : "deny");
64 wordlistAdd(&text
, act
? act
: "???");
68 wordlist
*rule
= (*node
)->dump();
69 wordlistAddWl(&text
, rule
);
70 wordlistDestroy(&rule
);
72 wordlistAdd(&text
, "\n");