]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/NoteData.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / acl / NoteData.cc
CommitLineData
bbc27441 1/*
5b74111a 2 * Copyright (C) 1996-2018 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
19ACLNoteData::ACLNoteData() : values(new ACLStringData)
20{}
21
22ACLNoteData::~ACLNoteData()
23{
24 delete values;
25}
26
27bool
76ee67ac 28ACLNoteData::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 38SBufList
4f8ca96e 39ACLNoteData::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
47void
48ACLNoteData::parse()
49{
16c5ad96 50 char* t = ConfigParser::strtokFile();
39baccc8
CT
51 assert (t != NULL);
52 name = t;
53 values->parse();
54}
55
56bool
57ACLNoteData::empty() const
58{
75d47340 59 return name.isEmpty();
39baccc8
CT
60}
61
76ee67ac 62ACLData<NotePairs::Entry *> *
39baccc8
CT
63ACLNoteData::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