]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/StringData.cc
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
);
39 splaystrcmp (char * const &l
, char * const &r
)
45 ACLStringData::insert(const char *value
)
47 values
= values
->insert(xstrdup(value
), splaystrcmp
);
51 ACLStringData::match(char const *toFind
)
53 if (!values
|| !toFind
)
56 debugs(28, 3, "aclMatchStringList: checking '" << toFind
<< "'");
58 values
= values
->splay((char *)toFind
, splaystrcmp
);
60 debugs(28, 3, "aclMatchStringList: '" << toFind
<< "' " << (splayLastResult
? "NOT found" : "found"));
62 return !splayLastResult
;
66 aclDumpStringWalkee(char * const & node_data
, void *outlist
)
68 /* outlist is really a SBufList* */
69 static_cast<SBufList
*>(outlist
)->push_back(SBuf(node_data
));
73 ACLStringData::dump() const
76 /* damn this is VERY inefficient for long ACL lists... filling
77 * a SBufList this way costs Sum(1,N) iterations. For instance
78 * a 1000-elements list will be filled in 499500 iterations.
80 values
->walk(aclDumpStringWalkee
, &sl
);
85 ACLStringData::parse()
89 while ((t
= strtokFile()))
90 values
= values
->insert(xstrdup(t
), splaystrcmp
);
94 ACLStringData::empty() const
96 return values
->empty();
99 ACLData
<char const *> *
100 ACLStringData::clone() const
102 /* Splay trees don't clone yet. */
104 return new ACLStringData(*this);