2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 28 Access Control */
12 #include "acl/Checklist.h"
13 #include "acl/StringData.h"
17 ACLStringData::ACLStringData() : values (NULL
)
20 ACLStringData::ACLStringData(ACLStringData
const &old
) : values (NULL
)
32 ACLStringData::~ACLStringData()
35 values
->destroy(xRefFree
);
41 splaystrcmp (char * const &l
, char * const &r
)
47 ACLStringData::insert(const char *value
)
49 values
->insert(xstrdup(value
), splaystrcmp
);
53 ACLStringData::match(char const *toFind
)
55 if (!values
|| !toFind
)
58 debugs(28, 3, "aclMatchStringList: checking '" << toFind
<< "'");
60 char * const * result
= values
->find(const_cast<char *>(toFind
), splaystrcmp
);
62 debugs(28, 3, "aclMatchStringList: '" << toFind
<< "' " << (result
? "found" : "NOT found"));
64 return (result
!= NULL
);
67 // visitor functor to collect the contents of the Arp Acl
68 struct StringDataAclDumpVisitor
{
70 void operator() (char * const& node_data
) {
71 contents
.push_back(SBuf(node_data
));
76 ACLStringData::dump() const
78 StringDataAclDumpVisitor visitor
;
79 values
->visit(visitor
);
80 return visitor
.contents
;
84 ACLStringData::parse()
88 while ((t
= strtokFile()))
89 values
->insert(xstrdup(t
), splaystrcmp
);
93 ACLStringData::empty() const
95 return values
->empty();
98 ACLData
<char const *> *
99 ACLStringData::clone() const
101 /* Splay trees don't clone yet. */
103 return new ACLStringData(*this);