]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/NoteData.cc
More conversions; now builds
[thirdparty/squid.git] / src / acl / NoteData.cc
CommitLineData
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
13ACLNoteData::ACLNoteData() : values(new ACLStringData)
14{}
15
16ACLNoteData::~ACLNoteData()
17{
18 delete values;
19}
20
21bool
22ACLNoteData::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
41bool
42ACLNoteData::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 54SBufList
39baccc8
CT
55ACLNoteData::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
63void
64ACLNoteData::parse()
65{
66 char* t = strtokFile();
67 assert (t != NULL);
68 name = t;
69 values->parse();
70}
71
72bool
73ACLNoteData::empty() const
74{
a1377698 75 return name.size() == 0;
39baccc8
CT
76}
77
78ACLData<HttpRequest *> *
79ACLNoteData::clone() const
80{
81 ACLNoteData * result = new ACLNoteData;
82 result->values = values->clone();
83 result->name = name;
84 return result;
85}