]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/NoteData.cc
Match stub_event.cc to event.cc changes
[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
32 for (Vector<NotePairs::Entry *>::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) {
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
54wordlist *
55ACLNoteData::dump()
56{
57 wordlist *W = NULL;
58 wordlistAdd(&W, name.termedBuf());
59 wordlist * dumpR = values->dump();
60 wordlistAddWl(&W, dumpR);
61 wordlistDestroy(&dumpR);
62 return W;
63}
64
65void
66ACLNoteData::parse()
67{
68 char* t = strtokFile();
69 assert (t != NULL);
70 name = t;
71 values->parse();
72}
73
74bool
75ACLNoteData::empty() const
76{
77 return name.undefined();
78}
79
80ACLData<HttpRequest *> *
81ACLNoteData::clone() const
82{
83 ACLNoteData * result = new ACLNoteData;
84 result->values = values->clone();
85 result->name = name;
86 return result;
87}