]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 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 | { |
75d47340 | 30 | if (entry->name().cmp(name) != 0) |
fef01789 CT |
31 | return false; // name mismatch |
32 | ||
33 | // a name-only note ACL matches any value; others require a values match | |
34 | return values->empty() || | |
75d47340 | 35 | values->match(entry->value()); |
39baccc8 CT |
36 | } |
37 | ||
9b859d6f | 38 | SBufList |
4f8ca96e | 39 | ACLNoteData::dump() const |
39baccc8 | 40 | { |
9b859d6f | 41 | SBufList sl; |
75d47340 | 42 | sl.push_back(name); |
524f5ff6 | 43 | sl.splice(sl.end(), values->dump()); |
9b859d6f | 44 | return sl; |
39baccc8 CT |
45 | } |
46 | ||
47 | void | |
48 | ACLNoteData::parse() | |
49 | { | |
16c5ad96 | 50 | char* t = ConfigParser::strtokFile(); |
39baccc8 CT |
51 | assert (t != NULL); |
52 | name = t; | |
53 | values->parse(); | |
54 | } | |
55 | ||
56 | bool | |
57 | ACLNoteData::empty() const | |
58 | { | |
75d47340 | 59 | return name.isEmpty(); |
39baccc8 CT |
60 | } |
61 | ||
76ee67ac | 62 | ACLData<NotePairs::Entry *> * |
39baccc8 CT |
63 | ACLNoteData::clone() const |
64 | { | |
65 | ACLNoteData * result = new ACLNoteData; | |
76ee67ac CT |
66 | result->values = dynamic_cast<ACLStringData*>(values->clone()); |
67 | assert(result->values); | |
39baccc8 CT |
68 | result->name = name; |
69 | return result; | |
70 | } | |
f53969cc | 71 |