]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 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/Stream.h" | |
16 | ||
17 | void | |
18 | ACLStringData::insert(const char *value) | |
19 | { | |
20 | stringValues.insert(SBuf(value)); | |
21 | } | |
22 | ||
23 | bool | |
24 | ACLStringData::match(const SBuf &tf) | |
25 | { | |
26 | if (stringValues.empty()) | |
27 | return 0; | |
28 | ||
29 | debugs(28, 3, "aclMatchStringList: checking '" << tf << "'"); | |
30 | ||
31 | bool found = (stringValues.find(tf) != stringValues.end()); | |
32 | debugs(28, 3, "aclMatchStringList: '" << tf << "' " << (found ? "found" : "NOT found")); | |
33 | ||
34 | return found; | |
35 | } | |
36 | ||
37 | // XXX: performance regression due to SBuf(char*) data-copies. | |
38 | bool | |
39 | ACLStringData::match(char const *toFind) | |
40 | { | |
41 | if (!toFind) { | |
42 | // TODO: Check whether we can Assure(toFind) instead. | |
43 | debugs(28, 3, "not matching a nil c-string"); | |
44 | return false; | |
45 | } | |
46 | return match(SBuf(toFind)); | |
47 | } | |
48 | ||
49 | SBufList | |
50 | ACLStringData::dump() const | |
51 | { | |
52 | SBufList sl; | |
53 | sl.insert(sl.end(), stringValues.begin(), stringValues.end()); | |
54 | return sl; | |
55 | } | |
56 | ||
57 | void | |
58 | ACLStringData::parse() | |
59 | { | |
60 | while (const char *t = ConfigParser::strtokFile()) | |
61 | stringValues.insert(SBuf(t)); | |
62 | } | |
63 | ||
64 | bool | |
65 | ACLStringData::empty() const | |
66 | { | |
67 | return stringValues.empty(); | |
68 | } | |
69 |