]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/acl/StringData.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / acl / StringData.cc
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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
9/* DEBUG: section 28 Access Control */
10
11#include "squid.h"
12#include "acl/Checklist.h"
13#include "acl/StringData.h"
14#include "ConfigParser.h"
15#include "Debug.h"
16
17ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues)
18{
19}
20
21void
22ACLStringData::insert(const char *value)
23{
24 stringValues.insert(SBuf(value));
25}
26
27bool
28ACLStringData::match(const SBuf &tf)
29{
30 if (stringValues.empty() || tf.isEmpty())
31 return 0;
32
33 debugs(28, 3, "aclMatchStringList: checking '" << tf << "'");
34
35 bool found = (stringValues.find(tf) != stringValues.end());
36 debugs(28, 3, "aclMatchStringList: '" << tf << "' " << (found ? "found" : "NOT found"));
37
38 return found;
39}
40
41// XXX: performance regression due to SBuf(char*) data-copies.
42bool
43ACLStringData::match(char const *toFind)
44{
45 return match(SBuf(toFind));
46}
47
48SBufList
49ACLStringData::dump() const
50{
51 SBufList sl;
52 sl.insert(sl.end(), stringValues.begin(), stringValues.end());
53 return sl;
54}
55
56void
57ACLStringData::parse()
58{
59 while (const char *t = ConfigParser::strtokFile())
60 stringValues.insert(SBuf(t));
61}
62
63bool
64ACLStringData::empty() const
65{
66 return stringValues.empty();
67}
68
69ACLData<char const *> *
70ACLStringData::clone() const
71{
72 /* Splay trees don't clone yet. */
73 return new ACLStringData(*this);
74}
75