]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Tree.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
13 CBDATA_NAMESPACED_CLASS_INIT(Acl
, Tree
);
16 Acl::Tree::winningAction() const
18 return actionAt(lastMatch_
- nodes
.begin());
22 Acl::Tree::lastAction() const
26 return actions
.back();
29 /// computes action that corresponds to the position of the matched rule
31 Acl::Tree::actionAt(const Nodes::size_type pos
) const
33 assert(pos
< nodes
.size());
35 assert(actions
.size() == nodes
.size());
38 // default for matched rules in trees without actions
39 return ACCESS_ALLOWED
;
43 Acl::Tree::add(ACL
*rule
, const allow_t
&action
)
45 // either all rules have actions or none
46 assert(nodes
.size() == actions
.size());
48 actions
.push_back(action
);
52 Acl::Tree::add(ACL
*rule
)
54 // either all rules have actions or none
55 assert(actions
.empty());
60 Acl::Tree::treeDump(const char *prefix
, const ActionToString
&convert
) const
63 Actions::const_iterator action
= actions
.begin();
64 typedef Nodes::const_iterator NCI
;
65 for (NCI node
= nodes
.begin(); node
!= nodes
.end(); ++node
) {
67 text
.push_back(SBuf(prefix
));
69 if (action
!= actions
.end()) {
70 const char *act
= convert
? convert
[action
->kind
] :
71 (*action
== ACCESS_ALLOWED
? "allow" : "deny");
72 text
.push_back(act
?SBuf(act
):SBuf("???"));
76 #if __cplusplus >= 201103L
77 text
.splice(text
.end(), (*node
)->dump());
79 // temp is needed until c++11 move constructor
80 SBufList temp
= (*node
)->dump();
81 text
.splice(text
.end(), temp
);
83 text
.push_back(SBuf("\n"));