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