]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2021 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 | /* DEBUG: section 28 Access Control */ | |
10 | ||
11 | #include "squid.h" | |
12 | #include "acl/Checklist.h" | |
13 | #include "acl/StringData.h" | |
14 | #include "ConfigParser.h" | |
15 | #include "Debug.h" | |
16 | ||
17 | ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues) | |
18 | { | |
19 | } | |
20 | ||
21 | void | |
22 | ACLStringData::insert(const char *value) | |
23 | { | |
24 | stringValues.insert(SBuf(value)); | |
25 | } | |
26 | ||
27 | bool | |
28 | ACLStringData::match(const SBuf &tf) | |
29 | { | |
30 | if (stringValues.empty() || tf.isEmpty()) | |
31 | return 0; | |
32 | ||
33 | debugs(28, 3, "aclMatchStringList: checking '" << tf << "'"); | |
34 | ||
35 | bool found = (stringValues.find(tf) != stringValues.end()); | |
36 | debugs(28, 3, "aclMatchStringList: '" << tf << "' " << (found ? "found" : "NOT found")); | |
37 | ||
38 | return found; | |
39 | } | |
40 | ||
41 | // XXX: performance regression due to SBuf(char*) data-copies. | |
42 | bool | |
43 | ACLStringData::match(char const *toFind) | |
44 | { | |
45 | return match(SBuf(toFind)); | |
46 | } | |
47 | ||
48 | SBufList | |
49 | ACLStringData::dump() const | |
50 | { | |
51 | SBufList sl; | |
52 | sl.insert(sl.end(), stringValues.begin(), stringValues.end()); | |
53 | return sl; | |
54 | } | |
55 | ||
56 | void | |
57 | ACLStringData::parse() | |
58 | { | |
59 | while (const char *t = ConfigParser::strtokFile()) | |
60 | stringValues.insert(SBuf(t)); | |
61 | } | |
62 | ||
63 | bool | |
64 | ACLStringData::empty() const | |
65 | { | |
66 | return stringValues.empty(); | |
67 | } | |
68 | ||
69 | ACLData<char const *> * | |
70 | ACLStringData::clone() const | |
71 | { | |
72 | /* Splay trees don't clone yet. */ | |
73 | return new ACLStringData(*this); | |
74 | } | |
75 |