]>
Commit | Line | Data |
---|---|---|
39baccc8 CT |
1 | #include "squid.h" |
2 | #include "acl/Acl.h" | |
3 | #include "acl/Checklist.h" | |
4 | #include "acl/NoteData.h" | |
5 | #include "acl/StringData.h" | |
6 | #include "cache_cf.h" | |
7 | #include "ConfigParser.h" | |
8 | #include "Debug.h" | |
9 | #include "HttpRequest.h" | |
10 | #include "Notes.h" | |
11 | #include "wordlist.h" | |
12 | ||
13 | ACLNoteData::ACLNoteData() : values(new ACLStringData) | |
14 | {} | |
15 | ||
16 | ACLNoteData::~ACLNoteData() | |
17 | { | |
18 | delete values; | |
19 | } | |
20 | ||
21 | bool | |
22 | ACLNoteData::matchNotes(NotePairs *note) | |
23 | { | |
24 | if (note == NULL) | |
25 | return false; | |
26 | ||
27 | debugs(28, 3, "Checking " << name); | |
28 | ||
29 | if (values->empty()) | |
30 | return (note->findFirst(name.termedBuf()) != NULL); | |
31 | ||
81481ec0 | 32 | for (std::vector<NotePairs::Entry *>::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) { |
39baccc8 CT |
33 | if ((*i)->name.cmp(name.termedBuf()) == 0) { |
34 | if (values->match((*i)->value.termedBuf())) | |
35 | return true; | |
36 | } | |
37 | } | |
38 | return false; | |
39 | } | |
40 | ||
41 | bool | |
42 | ACLNoteData::match(HttpRequest *request) | |
43 | { | |
44 | if (request->notes != NULL && matchNotes(request->notes.getRaw())) | |
45 | return true; | |
46 | #if USE_ADAPTATION | |
47 | const Adaptation::History::Pointer ah = request->adaptLogHistory(); | |
48 | if (ah != NULL && ah->metaHeaders != NULL && matchNotes(ah->metaHeaders.getRaw())) | |
49 | return true; | |
50 | #endif | |
51 | return false; | |
52 | } | |
53 | ||
9b859d6f | 54 | SBufList |
39baccc8 CT |
55 | ACLNoteData::dump() |
56 | { | |
9b859d6f FC |
57 | SBufList sl; |
58 | sl.push_back(SBuf(name)); | |
59 | sl.splice(sl.end(),values->dump()); | |
60 | return sl; | |
39baccc8 CT |
61 | } |
62 | ||
63 | void | |
64 | ACLNoteData::parse() | |
65 | { | |
66 | char* t = strtokFile(); | |
67 | assert (t != NULL); | |
68 | name = t; | |
69 | values->parse(); | |
70 | } | |
71 | ||
72 | bool | |
73 | ACLNoteData::empty() const | |
74 | { | |
a1377698 | 75 | return name.size() == 0; |
39baccc8 CT |
76 | } |
77 | ||
78 | ACLData<HttpRequest *> * | |
79 | ACLNoteData::clone() const | |
80 | { | |
81 | ACLNoteData * result = new ACLNoteData; | |
82 | result->values = values->clone(); | |
83 | result->name = name; | |
84 | return result; | |
85 | } |