#include "defines.h"
#include "dlink.h"
#include "MemPool.h"
+#include "SBufList.h"
#include <ostream>
#include <string>
virtual void parse() = 0;
virtual char const *typeString() const = 0;
virtual bool isProxyAuth() const;
- virtual wordlist *dump() const = 0;
+ virtual SBufList dump() const = 0;
virtual bool empty() const = 0;
virtual bool valid() const;
return new AllOf;
}
-wordlist*
+SBufList
Acl::AllOf::dump() const
{
- return empty() ? NULL : nodes.front()->dump();
+ return empty() ? SBufList() : nodes.front()->dump();
}
int
virtual char const *typeString() const;
virtual ACL *clone() const;
virtual void parse();
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
private:
/* Acl::InnerNode API */
return asnMatchIp(data, toMatch);
}
-wordlist *
+SBufList
ACLASN::dump()
{
- wordlist *W = NULL;
- char buf[32];
+ SBufList sl;
+
CbDataList<int> *ldata = data;
while (ldata != NULL) {
- snprintf(buf, sizeof(buf), "%d", ldata->element);
- wordlistAdd(&W, buf);
+ SBuf s;
+ s.Printf("%d", ldata->element);
+ sl.push_back(s);
ldata = ldata->next;
}
- return W;
+ return sl;
}
bool
#include "acl/Strategised.h"
#include "CbDataList.h"
#include "ip/Address.h"
+#include "SBufList.h"
int asnMatchIp(CbDataList<int> *, Ip::Address &);
virtual ~ACLASN();
virtual bool match(Ip::Address);
- virtual wordlist *dump();
+ virtual SBufList dump();
virtual void parse();
bool empty() const;
virtual ACLData<Ip::Address> *clone() const;
return NULL;
}
-wordlist*
+SBufList
Acl::NotNode::dump() const
{
- wordlist *text = NULL;
- wordlistAdd(&text, name);
+ SBufList text;
+ text.push_back(SBuf(name));
return text;
}
virtual char const *typeString() const;
virtual ACL *clone() const;
virtual void parse();
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
/* Acl::InnerNode API */
virtual int doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const;
#ifndef SQUID_ACLDATA_H
#define SQUID_ACLDATA_H
-class wordlist;
+#include "SBufList.h"
/// \ingroup ACLAPI
template <class M>
virtual ~ACLData() {}
virtual bool match(M) =0;
- virtual wordlist *dump() =0;
+ virtual SBufList dump() =0;
virtual void parse() =0;
virtual ACLData *clone() const =0;
virtual void prepareForUse() {}
static void
aclDumpDomainListWalkee(char * const & node_data, void *outlist)
{
- /* outlist is really a wordlist ** */
- wordlistAdd((wordlist **)outlist, (char const *)node_data);
+ /* outlist is really a SBufList ** */
+ static_cast<SBufList *>(outlist)->push_back(SBuf(node_data));
}
-wordlist *
+SBufList
ACLDomainData::dump()
{
- wordlist *wl = NULL;
+ SBufList sl;
/* damn this is VERY inefficient for long ACL lists... filling
* a wordlist this way costs Sum(1,N) iterations. For instance
* a 1000-elements list will be filled in 499500 iterations.
*/
- domains->walk(aclDumpDomainListWalkee, &wl);
- return wl;
+ domains->walk(aclDumpDomainListWalkee, &sl);
+ return sl;
}
void
virtual ~ACLDomainData();
bool match(char const *);
- wordlist *dump();
+ SBufList dump();
void parse();
bool empty() const;
virtual ACLData<char const *> *clone() const;
}
}
-wordlist *
+SBufList
ACLExtUser::dump() const
{
return data->dump();
virtual void parse();
virtual int match(ACLChecklist *checklist);
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
virtual bool empty () const;
virtual ACL *clone()const;
#include "acl/HierCodeData.h"
#include "cache_cf.h"
#include "hier_code.h"
-#include "wordlist.h"
ACLHierCodeData::ACLHierCodeData()
{
return values[toFind];
}
-wordlist *
+SBufList
ACLHierCodeData::dump()
{
- wordlist *W = NULL;
+ SBufList sl;
for (hier_code iter=HIER_NONE; iter<HIER_MAX; ++iter) {
if (!values[iter]) continue;
- wordlistAdd(&W, hier_code_str[iter]);
+ sl.push_back(SBuf(hier_code_str[iter]));
}
- return W;
+ return sl;
}
void
ACLHierCodeData &operator= (ACLHierCodeData const &);
virtual ~ACLHierCodeData();
bool match(hier_code);
- wordlist *dump();
+ SBufList dump();
void parse();
bool empty() const;
virtual ACLData<hier_code> *clone() const;
return regex_rule->match(cvalue.c_str());
}
-wordlist *
+SBufList
ACLHTTPHeaderData::dump()
{
- wordlist *W = NULL;
- wordlistAdd(&W, hdrName.termedBuf());
- wordlist * regex_dump = regex_rule->dump();
- wordlistAddWl(&W, regex_dump);
- wordlistDestroy(®ex_dump);
- return W;
+ SBufList sl;
+ sl.push_back(SBuf(hdrName));
+ sl.splice(sl.end(),regex_rule->dump());
+ return sl;
}
void
ACLHTTPHeaderData();
virtual ~ACLHTTPHeaderData();
virtual bool match(HttpHeader* hdr);
- virtual wordlist *dump();
+ virtual SBufList dump();
virtual void parse();
virtual bool empty() const;
virtual ACLData<HttpHeader*> *clone() const;
acl_httpstatus_data::acl_httpstatus_data(int x, int y) : status1(x), status2(y) { ; }
-void acl_httpstatus_data::toStr(char* buf, int len) const
+SBuf
+acl_httpstatus_data::repr() const
{
+ SBuf rv;
if (status2 == INT_MAX)
- snprintf(buf, len, "%d-", status1);
+ rv.Printf("%d-", status1);
else if (status1 == status2)
- snprintf(buf, len, "%d", status1);
+ rv.Printf("%d", status1);
else
- snprintf(buf, len, "%d-%d", status1, status2);
+ rv.Printf("%d-%d", status1, status2);
+ return rv;
}
int acl_httpstatus_data::compare(acl_httpstatus_data* const& a, acl_httpstatus_data* const& b)
ret = aclHTTPStatusCompare(a, b);
if (ret == 0) {
- char bufa[8];
- char bufb[8];
- a->toStr(bufa, sizeof(bufa));
- b->toStr(bufb, sizeof(bufb));
- debugs(28, DBG_CRITICAL, "WARNING: '" << bufa << "' is a subrange of '" << bufb << "'");
- debugs(28, DBG_CRITICAL, "WARNING: because of this '" << bufa << "' is ignored to keep splay tree searching predictable");
- debugs(28, DBG_CRITICAL, "WARNING: You should probably remove '" << bufb << "' from the ACL named '" << AclMatchedName << "'");
+ SBuf sa, sb;
+ sa=a->repr();
+ sb=b->repr();
+ debugs(28, DBG_CRITICAL, "WARNING: '" << sa << "' is a subrange of '" << sb << "'");
+ debugs(28, DBG_CRITICAL, "WARNING: because of this '" << sa << "' is ignored to keep splay tree searching predictable");
+ debugs(28, DBG_CRITICAL, "WARNING: You should probably remove '" << sb << "' from the ACL named '" << AclMatchedName << "'");
}
return ret;
static void
aclDumpHTTPStatusListWalkee(acl_httpstatus_data * const &node, void *state)
{
- static char buf[8];
- node->toStr(buf, sizeof(buf));
- wordlistAdd((wordlist **)state, buf);
+ // state is a SBufList*
+ static_cast<SBufList *>(state)->push_back(node->repr());
}
-wordlist *
+SBufList
ACLHTTPStatus::dump() const
{
- wordlist *w = NULL;
+ SBufList w;
data->walk(aclDumpHTTPStatusListWalkee, &w);
return w;
}
int status1, status2;
acl_httpstatus_data(int);
acl_httpstatus_data(int, int);
- void toStr(char* buf, int len) const;
+ SBuf repr() const; // was toStr
static int compare(acl_httpstatus_data* const& a, acl_httpstatus_data* const& b);
};
virtual char const *typeString() const;
virtual void parse();
virtual int match(ACLChecklist *checklist);
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
virtual bool empty () const;
virtual bool requiresReply() const { return true; }
return;
}
-wordlist*
+SBufList
Acl::InnerNode::dump() const
{
- wordlist *values = NULL;
+ SBufList rv;
for (Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
- wordlistAdd(&values, (*i)->name);
- return values;
+ rv.push_back(SBuf((*i)->name));
+ return rv;
}
int
/* ACL API */
virtual void prepareForUse();
virtual bool empty() const;
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
/// parses one "acl name type acl1 acl2..." line, appending to nodes
void lineParse();
ACLIntRange::~ACLIntRange ()
{}
-wordlist *
+SBufList
ACLIntRange::dump ()
{
- wordlist *W = NULL;
- char buf[32];
+ SBufList sl;
CbDataListIterator<RangeType> iter(ranges);
while (!iter.end()) {
+ SBuf sb;
const RangeType & element = iter.next();
if (element.size() == 1)
- snprintf(buf, sizeof(buf), "%d", element.start);
+ sb.Printf("%d", element.start);
else
- snprintf(buf, sizeof(buf), "%d-%d", element.start, element.end-1);
+ sb.Printf("%d-%d", element.start, element.end-1);
- wordlistAdd(&W, buf);
+ sl.push_back(sb);
}
- return W;
+ return sl;
}
#include "acl/Data.h"
#include "CbDataList.h"
#include "Range.h"
+#include "SBufList.h"
/// \ingroup ACLAPI
class ACLIntRange : public ACLData<int>
virtual ~ACLIntRange();
virtual bool match(int);
- virtual wordlist *dump();
+ virtual SBufList dump();
virtual void parse();
virtual bool empty() const;
virtual ACLData<int> *clone() const;
data->destroy(IPSplay::DefaultFree);
}
-wordlist *
+SBufList
ACLIP::dump() const
{
- wordlist *w = NULL;
- data->walk (DumpIpListWalkee, &w);
- return w;
+ SBufList sl;
+ data->walk (DumpIpListWalkee, &sl);
+ return sl;
}
bool
acl_ip_data (Ip::Address const &, Ip::Address const &, Ip::Address const &, acl_ip_data *);
void toStr(char *buf, int len) const;
+ SBuf toSBuf() const;
Ip::Address addr1;
virtual void parse();
// virtual bool isProxyAuth() const {return true;}
virtual int match(ACLChecklist *checklist) = 0;
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
virtual bool empty () const;
protected:
return 0;
}
-wordlist *
+SBufList
ACLRegexData::dump()
{
- wordlist *W = NULL;
+ SBufList sl;
RegexList *temp = data;
int flags = REG_EXTENDED | REG_NOSUB;
while (temp != NULL) {
if (temp->flags != flags) {
if ((temp->flags®_ICASE) != 0) {
- wordlistAdd(&W, "-i");
+ sl.push_back(SBuf("-i"));
} else {
- wordlistAdd(&W, "+i");
+ sl.push_back(SBuf("+i"));
}
flags = temp->flags;
}
- wordlistAdd(&W, temp->pattern);
+ sl.push_back(SBuf(temp->pattern));
temp = temp->next;
}
- return W;
+ return sl;
}
static const char *
#include "acl/Data.h"
#include "MemPool.h"
+#include "SBufList.h"
class RegexList;
virtual ~ACLRegexData();
virtual bool match(char const *user);
- virtual wordlist *dump();
+ virtual SBufList dump();
virtual void parse();
virtual bool empty() const;
virtual ACLData<char const *> *clone() const;
virtual void parse();
virtual int match(ACLChecklist *checklist);
virtual int match (M const &);
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
virtual bool empty () const;
virtual bool valid () const;
virtual ACL *clone()const;
}
template <class MatchType>
-wordlist *
+SBufList
ACLStrategised<MatchType>::dump() const
{
return data->dump();
static void
aclDumpStringWalkee(char * const & node_data, void *outlist)
{
- /* outlist is really a wordlist ** */
- wordlistAdd((wordlist **)outlist, node_data);
+ /* outlist is really a SBufList* */
+ static_cast<SBufList*>(outlist)->push_back(SBuf(node_data));
}
-wordlist *
+SBufList
ACLStringData::dump()
{
- wordlist *wl = NULL;
+ SBufList sl;
/* damn this is VERY inefficient for long ACL lists... filling
* a wordlist this way costs Sum(1,N) iterations. For instance
* a 1000-elements list will be filled in 499500 iterations.
*/
- values->walk(aclDumpStringWalkee, &wl);
- return wl;
+ values->walk(aclDumpStringWalkee, &sl);
+ return sl;
}
void
ACLStringData &operator= (ACLStringData const &);
virtual ~ACLStringData();
bool match(char const *);
- wordlist *dump();
+ SBufList dump();
virtual void parse();
bool empty() const;
virtual ACLData<char const *> *clone() const;
return 0;
}
-wordlist *
+SBufList
ACLTimeData::dump()
{
- wordlist *W = NULL;
- char buf[128];
+ SBufList sl;
ACLTimeData *t = this;
while (t != NULL) {
- snprintf(buf, sizeof(buf), "%c%c%c%c%c%c%c %02d:%02d-%02d:%02d",
+ SBuf s;
+ s.Printf("%c%c%c%c%c%c%c %02d:%02d-%02d:%02d",
t->weekbits & ACL_SUNDAY ? 'S' : '-',
t->weekbits & ACL_MONDAY ? 'M' : '-',
t->weekbits & ACL_TUESDAY ? 'T' : '-',
t->weekbits & ACL_FRIDAY ? 'F' : '-',
t->weekbits & ACL_SATURDAY ? 'A' : '-',
t->start / 60, t->start % 60, t->stop / 60, t->stop % 60);
- wordlistAdd(&W, buf);
+ sl.push_back(s);
t = t->next;
}
- return W;
+ return sl;
}
void
ACLTimeData&operator=(ACLTimeData const &);
virtual ~ACLTimeData();
bool match(time_t);
- wordlist *dump();
+ SBufList dump();
void parse();
bool empty() const;
virtual ACLData<time_t> *clone() const;
InnerNode::add(rule);
}
-wordlist*
+SBufList
Acl::Tree::treeDump(const char *prefix, const ActionToString &convert) const
{
- wordlist *text = NULL;
+ SBufList text;
Actions::const_iterator action = actions.begin();
typedef Nodes::const_iterator NCI;
for (NCI node = nodes.begin(); node != nodes.end(); ++node) {
- wordlistAdd(&text, prefix);
+ text.push_back(SBuf(prefix));
if (action != actions.end()) {
const char *act = convert ? convert[action->kind] :
(*action == ACCESS_ALLOWED ? "allow" : "deny");
- wordlistAdd(&text, act ? act : "???");
+ text.push_back(act?SBuf(act):SBuf("???"));
++action;
}
- wordlist *rule = (*node)->dump();
- wordlistAddWl(&text, rule);
- wordlistDestroy(&rule);
-
- wordlistAdd(&text, "\n");
+ text.splice(text.end(),(*node)->dump());
+ text.push_back(SBuf("\n"));
}
return text;
}
#define SQUID_ACL_TREE_H
#include "acl/BoolOps.h"
+#include "SBufList.h"
namespace Acl
{
/// dumps <name, action, rule, new line> tuples
/// action.kind is mapped to a string using the supplied conversion table
typedef const char **ActionToString;
- wordlist* treeDump(const char *name, const ActionToString &convert) const;
+ SBufList treeDump(const char *name, const ActionToString &convert) const;
/// Returns the corresponding action after a successful tree match.
allow_t winningAction() const;
static void
aclDumpUserListWalkee(char * const & node_data, void *outlist)
{
- /* outlist is really a wordlist ** */
- wordlistAdd((wordlist **)outlist, (char const *)node_data);
+ /* outlist is really a SBufList* */
+ static_cast<SBufList *>(outlist)->push_back(SBuf(node_data));
}
-wordlist *
+SBufList
ACLUserData::dump()
{
- wordlist *wl = NULL;
+ SBufList sl;
if (flags.case_insensitive)
- wordlistAdd(&wl, "-i");
+ sl.push_back(SBuf("-i"));
/* damn this is VERY inefficient for long ACL lists... filling
* a wordlist this way costs Sum(1,N) iterations. For instance
* a 1000-elements list will be filled in 499500 iterations.
*/
if (flags.required)
- wordlistAdd(&wl, "REQUIRED");
+ sl.push_back(SBuf("REQUIRED"));
else if (names)
- names->walk(aclDumpUserListWalkee, &wl);
+ names->walk(aclDumpUserListWalkee, &sl);
- return wl;
+ return sl;
}
void
virtual ~ACLUserData();
bool match(char const *user);
- wordlist *dump();
+ SBufList dump();
void parse();
bool empty() const;
virtual ACLData<char const *> *clone() const;
}
}
-wordlist *
+SBufList
ACLProxyAuth::dump() const
{
return data->dump();
virtual bool isProxyAuth() const {return true;}
virtual int match(ACLChecklist *checklist);
- virtual wordlist *dump() const;
+ virtual SBufList dump() const;
virtual bool valid() const;
virtual bool empty() const;
virtual bool requiresRequest() const {return true;}