]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
39baccc8 CT |
9 | #include "squid.h" |
10 | #include "acl/Acl.h" | |
11 | #include "acl/Checklist.h" | |
12 | #include "acl/NoteData.h" | |
13 | #include "acl/StringData.h" | |
39baccc8 CT |
14 | #include "ConfigParser.h" |
15 | #include "Debug.h" | |
ac38abee | 16 | #include "sbuf/StringConvert.h" |
39baccc8 CT |
17 | #include "wordlist.h" |
18 | ||
19 | ACLNoteData::ACLNoteData() : values(new ACLStringData) | |
20 | {} | |
21 | ||
22 | ACLNoteData::~ACLNoteData() | |
23 | { | |
24 | delete values; | |
25 | } | |
26 | ||
27 | bool | |
76ee67ac | 28 | ACLNoteData::match(NotePairs::Entry *entry) |
39baccc8 | 29 | { |
fef01789 CT |
30 | if (entry->name.cmp(name.termedBuf()) != 0) |
31 | return false; // name mismatch | |
32 | ||
33 | // a name-only note ACL matches any value; others require a values match | |
34 | return values->empty() || | |
a2c34645 | 35 | values->match(entry->value.termedBuf()); |
39baccc8 CT |
36 | } |
37 | ||
9b859d6f | 38 | SBufList |
4f8ca96e | 39 | ACLNoteData::dump() const |
39baccc8 | 40 | { |
9b859d6f | 41 | SBufList sl; |
0d1c9fe8 | 42 | sl.push_back(StringToSBuf(name)); |
524f5ff6 AJ |
43 | #if __cplusplus >= 201103L |
44 | sl.splice(sl.end(), values->dump()); | |
45 | #else | |
7d75c222 FC |
46 | // temp is needed until c++11 move constructor |
47 | SBufList temp = values->dump(); | |
48 | sl.splice(sl.end(), temp); | |
524f5ff6 | 49 | #endif |
9b859d6f | 50 | return sl; |
39baccc8 CT |
51 | } |
52 | ||
53 | void | |
54 | ACLNoteData::parse() | |
55 | { | |
16c5ad96 | 56 | char* t = ConfigParser::strtokFile(); |
39baccc8 CT |
57 | assert (t != NULL); |
58 | name = t; | |
59 | values->parse(); | |
60 | } | |
61 | ||
62 | bool | |
63 | ACLNoteData::empty() const | |
64 | { | |
a1377698 | 65 | return name.size() == 0; |
39baccc8 CT |
66 | } |
67 | ||
76ee67ac | 68 | ACLData<NotePairs::Entry *> * |
39baccc8 CT |
69 | ACLNoteData::clone() const |
70 | { | |
71 | ACLNoteData * result = new ACLNoteData; | |
76ee67ac CT |
72 | result->values = dynamic_cast<ACLStringData*>(values->clone()); |
73 | assert(result->values); | |
39baccc8 CT |
74 | result->name = name; |
75 | return result; | |
76 | } | |
f53969cc | 77 |