From 8966008ba2d61288cc91c9b7e201fddeaf520552 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Fri, 11 Apr 2014 18:00:36 +0200 Subject: [PATCH] Interim. Refactor ACL::dump to SBufList instead of wordlist* --- src/acl/Acl.h | 3 ++- src/acl/AllOf.cc | 4 ++-- src/acl/AllOf.h | 2 +- src/acl/Asn.cc | 13 +++++++------ src/acl/Asn.h | 3 ++- src/acl/BoolOps.cc | 6 +++--- src/acl/BoolOps.h | 2 +- src/acl/Data.h | 4 ++-- src/acl/DomainData.cc | 12 ++++++------ src/acl/DomainData.h | 2 +- src/acl/ExtUser.cc | 2 +- src/acl/ExtUser.h | 2 +- src/acl/HierCodeData.cc | 9 ++++----- src/acl/HierCodeData.h | 2 +- src/acl/HttpHeaderData.cc | 12 +++++------- src/acl/HttpHeaderData.h | 2 +- src/acl/HttpStatus.cc | 33 +++++++++++++++++---------------- src/acl/HttpStatus.h | 4 ++-- src/acl/InnerNode.cc | 8 ++++---- src/acl/InnerNode.h | 2 +- src/acl/IntRange.cc | 14 +++++++------- src/acl/IntRange.h | 3 ++- src/acl/Ip.cc | 8 ++++---- src/acl/Ip.h | 3 ++- src/acl/RegexData.cc | 12 ++++++------ src/acl/RegexData.h | 3 ++- src/acl/Strategised.h | 4 ++-- src/acl/StringData.cc | 12 ++++++------ src/acl/StringData.h | 2 +- src/acl/TimeData.cc | 12 ++++++------ src/acl/TimeData.h | 2 +- src/acl/Tree.cc | 15 ++++++--------- src/acl/Tree.h | 3 ++- src/acl/UserData.cc | 16 ++++++++-------- src/acl/UserData.h | 2 +- src/auth/AclProxyAuth.cc | 2 +- src/auth/AclProxyAuth.h | 2 +- 37 files changed, 122 insertions(+), 120 deletions(-) diff --git a/src/acl/Acl.h b/src/acl/Acl.h index cbefd6423e..95f52656ed 100644 --- a/src/acl/Acl.h +++ b/src/acl/Acl.h @@ -38,6 +38,7 @@ #include "defines.h" #include "dlink.h" #include "MemPool.h" +#include "SBufList.h" #include #include @@ -121,7 +122,7 @@ public: 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; diff --git a/src/acl/AllOf.cc b/src/acl/AllOf.cc index 876535602d..3dccf6eb76 100644 --- a/src/acl/AllOf.cc +++ b/src/acl/AllOf.cc @@ -17,10 +17,10 @@ Acl::AllOf::clone() const return new AllOf; } -wordlist* +SBufList Acl::AllOf::dump() const { - return empty() ? NULL : nodes.front()->dump(); + return empty() ? SBufList() : nodes.front()->dump(); } int diff --git a/src/acl/AllOf.h b/src/acl/AllOf.h index 1358303aa5..75c6c200bf 100644 --- a/src/acl/AllOf.h +++ b/src/acl/AllOf.h @@ -18,7 +18,7 @@ public: virtual char const *typeString() const; virtual ACL *clone() const; virtual void parse(); - virtual wordlist *dump() const; + virtual SBufList dump() const; private: /* Acl::InnerNode API */ diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index bea2a9ab8c..c4276801a2 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -551,20 +551,21 @@ ACLASN::match(Ip::Address toMatch) return asnMatchIp(data, toMatch); } -wordlist * +SBufList ACLASN::dump() { - wordlist *W = NULL; - char buf[32]; + SBufList sl; + CbDataList *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 diff --git a/src/acl/Asn.h b/src/acl/Asn.h index d6932d7847..48cf8416d4 100644 --- a/src/acl/Asn.h +++ b/src/acl/Asn.h @@ -37,6 +37,7 @@ #include "acl/Strategised.h" #include "CbDataList.h" #include "ip/Address.h" +#include "SBufList.h" int asnMatchIp(CbDataList *, Ip::Address &); @@ -56,7 +57,7 @@ public: virtual ~ACLASN(); virtual bool match(Ip::Address); - virtual wordlist *dump(); + virtual SBufList dump(); virtual void parse(); bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/BoolOps.cc b/src/acl/BoolOps.cc index 3b8c89f771..5f70d98e39 100644 --- a/src/acl/BoolOps.cc +++ b/src/acl/BoolOps.cc @@ -52,11 +52,11 @@ Acl::NotNode::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; } diff --git a/src/acl/BoolOps.h b/src/acl/BoolOps.h index d06c8a94fc..82a6b1860a 100644 --- a/src/acl/BoolOps.h +++ b/src/acl/BoolOps.h @@ -23,7 +23,7 @@ private: 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; diff --git a/src/acl/Data.h b/src/acl/Data.h index 1ea9e061e3..a099323793 100644 --- a/src/acl/Data.h +++ b/src/acl/Data.h @@ -32,7 +32,7 @@ #ifndef SQUID_ACLDATA_H #define SQUID_ACLDATA_H -class wordlist; +#include "SBufList.h" /// \ingroup ACLAPI template @@ -44,7 +44,7 @@ public: 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() {} diff --git a/src/acl/DomainData.cc b/src/acl/DomainData.cc index b2f6e8be5a..213cf16a3a 100644 --- a/src/acl/DomainData.cc +++ b/src/acl/DomainData.cc @@ -140,20 +140,20 @@ ACLDomainData::match(char const *host) 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(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 diff --git a/src/acl/DomainData.h b/src/acl/DomainData.h index 7839a8f75d..a8981e14cf 100644 --- a/src/acl/DomainData.h +++ b/src/acl/DomainData.h @@ -46,7 +46,7 @@ public: virtual ~ACLDomainData(); bool match(char const *); - wordlist *dump(); + SBufList dump(); void parse(); bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/ExtUser.cc b/src/acl/ExtUser.cc index fb3e157814..073f71baf4 100644 --- a/src/acl/ExtUser.cc +++ b/src/acl/ExtUser.cc @@ -85,7 +85,7 @@ ACLExtUser::match(ACLChecklist *cl) } } -wordlist * +SBufList ACLExtUser::dump() const { return data->dump(); diff --git a/src/acl/ExtUser.h b/src/acl/ExtUser.h index fda9d93242..1d586c7ea4 100644 --- a/src/acl/ExtUser.h +++ b/src/acl/ExtUser.h @@ -55,7 +55,7 @@ public: virtual void parse(); virtual int match(ACLChecklist *checklist); - virtual wordlist *dump() const; + virtual SBufList dump() const; virtual bool empty () const; virtual ACL *clone()const; diff --git a/src/acl/HierCodeData.cc b/src/acl/HierCodeData.cc index a5c224fc69..14f7957924 100644 --- a/src/acl/HierCodeData.cc +++ b/src/acl/HierCodeData.cc @@ -3,7 +3,6 @@ #include "acl/HierCodeData.h" #include "cache_cf.h" #include "hier_code.h" -#include "wordlist.h" ACLHierCodeData::ACLHierCodeData() { @@ -25,17 +24,17 @@ ACLHierCodeData::match(hier_code toFind) return values[toFind]; } -wordlist * +SBufList ACLHierCodeData::dump() { - wordlist *W = NULL; + SBufList sl; for (hier_code iter=HIER_NONE; iter *clone() const; diff --git a/src/acl/HttpHeaderData.cc b/src/acl/HttpHeaderData.cc index 904c80bed7..ecbb5fce17 100644 --- a/src/acl/HttpHeaderData.cc +++ b/src/acl/HttpHeaderData.cc @@ -80,15 +80,13 @@ ACLHTTPHeaderData::match(HttpHeader* hdr) 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 diff --git a/src/acl/HttpHeaderData.h b/src/acl/HttpHeaderData.h index d2a5bd0103..ea05d0e7bc 100644 --- a/src/acl/HttpHeaderData.h +++ b/src/acl/HttpHeaderData.h @@ -54,7 +54,7 @@ public: ACLHTTPHeaderData(); virtual ~ACLHTTPHeaderData(); virtual bool match(HttpHeader* hdr); - virtual wordlist *dump(); + virtual SBufList dump(); virtual void parse(); virtual bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/HttpStatus.cc b/src/acl/HttpStatus.cc index f5cc88fd57..541b3cce87 100644 --- a/src/acl/HttpStatus.cc +++ b/src/acl/HttpStatus.cc @@ -50,14 +50,17 @@ acl_httpstatus_data::acl_httpstatus_data(int x) : status1(x), status2(x) { ; } 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) @@ -69,13 +72,12 @@ int acl_httpstatus_data::compare(acl_httpstatus_data* const& a, acl_httpstatus_d 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; @@ -184,15 +186,14 @@ aclHTTPStatusCompare(acl_httpstatus_data * const &a, acl_httpstatus_data * const 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(state)->push_back(node->repr()); } -wordlist * +SBufList ACLHTTPStatus::dump() const { - wordlist *w = NULL; + SBufList w; data->walk(aclDumpHTTPStatusListWalkee, &w); return w; } diff --git a/src/acl/HttpStatus.h b/src/acl/HttpStatus.h index 5f03112181..c28f2d12b1 100644 --- a/src/acl/HttpStatus.h +++ b/src/acl/HttpStatus.h @@ -42,7 +42,7 @@ struct acl_httpstatus_data { 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); }; @@ -63,7 +63,7 @@ public: 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; } diff --git a/src/acl/InnerNode.cc b/src/acl/InnerNode.cc index b8bc27c7c4..4e0275e606 100644 --- a/src/acl/InnerNode.cc +++ b/src/acl/InnerNode.cc @@ -64,13 +64,13 @@ Acl::InnerNode::lineParse() 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 diff --git a/src/acl/InnerNode.h b/src/acl/InnerNode.h index 81865dbbe4..2a38a0a274 100644 --- a/src/acl/InnerNode.h +++ b/src/acl/InnerNode.h @@ -24,7 +24,7 @@ public: /* 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(); diff --git a/src/acl/IntRange.cc b/src/acl/IntRange.cc index 1e4c1a453e..ea68fc464b 100644 --- a/src/acl/IntRange.cc +++ b/src/acl/IntRange.cc @@ -112,24 +112,24 @@ ACLIntRange::clone() const ACLIntRange::~ACLIntRange () {} -wordlist * +SBufList ACLIntRange::dump () { - wordlist *W = NULL; - char buf[32]; + SBufList sl; CbDataListIterator 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; } diff --git a/src/acl/IntRange.h b/src/acl/IntRange.h index 946290c60f..1faf726ad6 100644 --- a/src/acl/IntRange.h +++ b/src/acl/IntRange.h @@ -36,6 +36,7 @@ #include "acl/Data.h" #include "CbDataList.h" #include "Range.h" +#include "SBufList.h" /// \ingroup ACLAPI class ACLIntRange : public ACLData @@ -46,7 +47,7 @@ public: virtual ~ACLIntRange(); virtual bool match(int); - virtual wordlist *dump(); + virtual SBufList dump(); virtual void parse(); virtual bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/Ip.cc b/src/acl/Ip.cc index 81ff1becdb..64960b8bd9 100644 --- a/src/acl/Ip.cc +++ b/src/acl/Ip.cc @@ -528,12 +528,12 @@ ACLIP::~ACLIP() 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 diff --git a/src/acl/Ip.h b/src/acl/Ip.h index 662d41424b..616a622002 100644 --- a/src/acl/Ip.h +++ b/src/acl/Ip.h @@ -50,6 +50,7 @@ public: 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; @@ -85,7 +86,7 @@ public: 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: diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc index 63ebe2db14..96b31a0162 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -101,28 +101,28 @@ ACLRegexData::match(char const *word) 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 * diff --git a/src/acl/RegexData.h b/src/acl/RegexData.h index 87ca21f52c..5cc90da7c4 100644 --- a/src/acl/RegexData.h +++ b/src/acl/RegexData.h @@ -34,6 +34,7 @@ #include "acl/Data.h" #include "MemPool.h" +#include "SBufList.h" class RegexList; @@ -45,7 +46,7 @@ public: virtual ~ACLRegexData(); virtual bool match(char const *user); - virtual wordlist *dump(); + virtual SBufList dump(); virtual void parse(); virtual bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/Strategised.h b/src/acl/Strategised.h index 6a2e276c09..4beeea3c96 100644 --- a/src/acl/Strategised.h +++ b/src/acl/Strategised.h @@ -63,7 +63,7 @@ public: 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; @@ -161,7 +161,7 @@ ACLStrategised::match(MatchType const &toFind) } template -wordlist * +SBufList ACLStrategised::dump() const { return data->dump(); diff --git a/src/acl/StringData.cc b/src/acl/StringData.cc index c67fd456d2..60dbb544d2 100644 --- a/src/acl/StringData.cc +++ b/src/acl/StringData.cc @@ -90,20 +90,20 @@ ACLStringData::match(char const *toFind) 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(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 diff --git a/src/acl/StringData.h b/src/acl/StringData.h index 6da50f37ab..a637a6dc67 100644 --- a/src/acl/StringData.h +++ b/src/acl/StringData.h @@ -48,7 +48,7 @@ public: ACLStringData &operator= (ACLStringData const &); virtual ~ACLStringData(); bool match(char const *); - wordlist *dump(); + SBufList dump(); virtual void parse(); bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/TimeData.cc b/src/acl/TimeData.cc index 6f8a3da20a..98fb423d27 100644 --- a/src/acl/TimeData.cc +++ b/src/acl/TimeData.cc @@ -97,15 +97,15 @@ ACLTimeData::match(time_t when) 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' : '-', @@ -114,11 +114,11 @@ ACLTimeData::dump() 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 diff --git a/src/acl/TimeData.h b/src/acl/TimeData.h index dca42ac47e..74b5f03f53 100644 --- a/src/acl/TimeData.h +++ b/src/acl/TimeData.h @@ -48,7 +48,7 @@ public: ACLTimeData&operator=(ACLTimeData const &); virtual ~ACLTimeData(); bool match(time_t); - wordlist *dump(); + SBufList dump(); void parse(); bool empty() const; virtual ACLData *clone() const; diff --git a/src/acl/Tree.cc b/src/acl/Tree.cc index 4b79abaa94..06b745cd85 100644 --- a/src/acl/Tree.cc +++ b/src/acl/Tree.cc @@ -48,28 +48,25 @@ Acl::Tree::add(ACL *rule) 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; } diff --git a/src/acl/Tree.h b/src/acl/Tree.h index a372839192..742f4474d9 100644 --- a/src/acl/Tree.h +++ b/src/acl/Tree.h @@ -2,6 +2,7 @@ #define SQUID_ACL_TREE_H #include "acl/BoolOps.h" +#include "SBufList.h" namespace Acl { @@ -14,7 +15,7 @@ public: /// dumps 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; diff --git a/src/acl/UserData.cc b/src/acl/UserData.cc index 499400d0e3..08af4ee6c2 100644 --- a/src/acl/UserData.cc +++ b/src/acl/UserData.cc @@ -97,28 +97,28 @@ ACLUserData::match(char const *user) 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(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 diff --git a/src/acl/UserData.h b/src/acl/UserData.h index 0abec76633..4c32c228e2 100644 --- a/src/acl/UserData.h +++ b/src/acl/UserData.h @@ -45,7 +45,7 @@ public: virtual ~ACLUserData(); bool match(char const *user); - wordlist *dump(); + SBufList dump(); void parse(); bool empty() const; virtual ACLData *clone() const; diff --git a/src/auth/AclProxyAuth.cc b/src/auth/AclProxyAuth.cc index 0835f12070..840fc53892 100644 --- a/src/auth/AclProxyAuth.cc +++ b/src/auth/AclProxyAuth.cc @@ -99,7 +99,7 @@ ACLProxyAuth::match(ACLChecklist *checklist) } } -wordlist * +SBufList ACLProxyAuth::dump() const { return data->dump(); diff --git a/src/auth/AclProxyAuth.h b/src/auth/AclProxyAuth.h index 636c857666..1b00f8224d 100644 --- a/src/auth/AclProxyAuth.h +++ b/src/auth/AclProxyAuth.h @@ -65,7 +65,7 @@ public: 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;} -- 2.47.2