]>
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(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
55 Actions::const_iterator action
= actions
.begin();
56 typedef Nodes::const_iterator NCI
;
57 for (NCI node
= nodes
.begin(); node
!= nodes
.end(); ++node
) {
59 text
.push_back(SBuf(prefix
));
61 if (action
!= actions
.end()) {
62 const char *act
= convert
? convert
[action
->kind
] :
63 (*action
== ACCESS_ALLOWED
? "allow" : "deny");
64 text
.push_back(act
?SBuf(act
):SBuf("???"));
68 // temp is needed until c++11 move constructor
69 SBufList temp
= (*node
)->dump();
70 text
.splice(text
.end(), temp
);
71 text
.push_back(SBuf("\n"));