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