From: Amos Jeffries Date: Thu, 29 Jan 2015 19:05:24 +0000 (-0800) Subject: Cleanup: remove strtokFile() wrapper function X-Git-Tag: merge-candidate-3-v1~311 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=16c5ad96bd635281c8b1b04af593a5af7b0fd667;p=thirdparty%2Fsquid.git Cleanup: remove strtokFile() wrapper function This global function was a wrapper around ConfigParser::strtokFile() which did nothing but cause additional dependency on cache_cf.h and cache_cf.cc. --- diff --git a/src/acl/Arp.cc b/src/acl/Arp.cc index d8e327e967..11fb0b6457 100644 --- a/src/acl/Arp.cc +++ b/src/acl/Arp.cc @@ -14,7 +14,6 @@ #include "acl/Arp.h" #include "acl/FilledChecklist.h" -#include "cache_cf.h" #include "Debug.h" #include "eui/Eui48.h" #include "globals.h" @@ -102,7 +101,7 @@ aclParseArpData(const char *t) void ACLARP::parse() { - while (const char *t = strtokFile()) { + while (const char *t = ConfigParser::strtokFile()) { if (Eui::Eui48 *q = aclParseArpData(t)) { aclArpData.insert(*q); delete q; diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index 1adb07f360..418bc98758 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -15,7 +15,6 @@ #include "acl/DestinationAsn.h" #include "acl/DestinationIp.h" #include "acl/SourceAsn.h" -#include "cache_cf.h" #include "FwdState.h" #include "HttpReply.h" #include "HttpRequest.h" @@ -26,7 +25,6 @@ #include "SquidConfig.h" #include "Store.h" #include "StoreClient.h" -#include "StoreClient.h" #define WHOIS_PORT 43 #define AS_REQBUF_SZ 4096 @@ -559,7 +557,7 @@ ACLASN::parse() char *t = NULL; for (Tail = curlist; *Tail; Tail = &((*Tail)->next)); - while ((t = strtokFile())) { + while ((t = ConfigParser::strtokFile())) { q = new CbDataList (atoi(t)); *(Tail) = q; Tail = &q->next; diff --git a/src/acl/AtStepData.cc b/src/acl/AtStepData.cc index dc5a69a639..bc238be0a1 100644 --- a/src/acl/AtStepData.cc +++ b/src/acl/AtStepData.cc @@ -13,6 +13,7 @@ #include "acl/AtStepData.h" #include "acl/Checklist.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "wordlist.h" @@ -53,7 +54,7 @@ ACLAtStepData::dump() const void ACLAtStepData::parse() { - while (const char *t = strtokFile()) { + while (const char *t = ConfigParser::strtokFile()) { if (strcasecmp(t, "SslBump1") == 0) { values.push_back(Ssl::bumpStep1); } else if (strcasecmp(t, "SslBump2") == 0) { diff --git a/src/acl/CertificateData.cc b/src/acl/CertificateData.cc index f85fe64c97..8afa166806 100644 --- a/src/acl/CertificateData.cc +++ b/src/acl/CertificateData.cc @@ -12,6 +12,7 @@ #include "acl/CertificateData.h" #include "acl/Checklist.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "wordlist.h" @@ -92,7 +93,7 @@ void ACLCertificateData::parse() { if (validAttributesStr) { - char *newAttribute = strtokFile(); + char *newAttribute = ConfigParser::strtokFile(); if (!newAttribute) { if (attributeIsOptional) diff --git a/src/acl/DomainData.cc b/src/acl/DomainData.cc index 4857323a09..cbefc12e6e 100644 --- a/src/acl/DomainData.cc +++ b/src/acl/DomainData.cc @@ -12,6 +12,7 @@ #include "acl/Checklist.h" #include "acl/DomainData.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "src/URL.h" #include "util.h" @@ -134,12 +135,10 @@ ACLDomainData::dump() const void ACLDomainData::parse() { - char *t = NULL; - if (!domains) domains = new Splay(); - while ((t = strtokFile())) { + while (char *t = ConfigParser::strtokFile()) { Tolower(t); domains->insert(xstrdup(t), aclDomainCompare); } diff --git a/src/acl/Eui64.cc b/src/acl/Eui64.cc index dc1731925b..d8b93d6b1f 100644 --- a/src/acl/Eui64.cc +++ b/src/acl/Eui64.cc @@ -14,7 +14,6 @@ #include "acl/Eui64.h" #include "acl/FilledChecklist.h" -#include "cache_cf.h" #include "Debug.h" #include "eui/Eui64.h" #include "globals.h" @@ -74,7 +73,7 @@ aclParseEuiData(const char *t) void ACLEui64::parse() { - while (const char * t = strtokFile()) { + while (const char * t = ConfigParser::strtokFile()) { if (Eui::Eui64 * q = aclParseEuiData(t)) { eui64Data.insert(*q); delete q; diff --git a/src/acl/HierCodeData.cc b/src/acl/HierCodeData.cc index 626c04d9b3..59d3561925 100644 --- a/src/acl/HierCodeData.cc +++ b/src/acl/HierCodeData.cc @@ -9,7 +9,7 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/HierCodeData.h" -#include "cache_cf.h" +#include "ConfigParser.h" #include "fatal.h" #include "hier_code.h" @@ -51,7 +51,7 @@ ACLHierCodeData::parse() { char *t = NULL; - while ((t = strtokFile())) { + while ((t = ConfigParser::strtokFile())) { for (hier_code iter = HIER_NONE; iter <= HIER_MAX; ++iter) { if (iter == HIER_MAX) { fatalf("ERROR: No such hier_code '%s'",t); diff --git a/src/acl/HttpHeaderData.cc b/src/acl/HttpHeaderData.cc index 9617078b84..68cae3ec94 100644 --- a/src/acl/HttpHeaderData.cc +++ b/src/acl/HttpHeaderData.cc @@ -13,7 +13,6 @@ #include "acl/Checklist.h" #include "acl/HttpHeaderData.h" #include "acl/RegexData.h" -#include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" #include "HttpHeaderTools.h" @@ -73,7 +72,7 @@ ACLHTTPHeaderData::dump() const void ACLHTTPHeaderData::parse() { - char* t = strtokFile(); + char* t = ConfigParser::strtokFile(); assert (t != NULL); hdrName = t; hdrId = httpHeaderIdByNameDef(hdrName.rawBuf(), hdrName.size()); diff --git a/src/acl/HttpStatus.cc b/src/acl/HttpStatus.cc index 715b847509..5dac3c9004 100644 --- a/src/acl/HttpStatus.cc +++ b/src/acl/HttpStatus.cc @@ -11,7 +11,6 @@ #include "squid.h" #include "acl/FilledChecklist.h" #include "acl/HttpStatus.h" -#include "cache_cf.h" #include "Debug.h" #include "HttpReply.h" @@ -120,14 +119,9 @@ ACLHTTPStatus::parse() void aclParseHTTPStatusList(Splay **curlist) { - char *t = NULL; - acl_httpstatus_data *q = NULL; - - while ((t = strtokFile())) { - if ((q = aclParseHTTPStatusData(t)) == NULL) - continue; - - (*curlist)->insert(q, acl_httpstatus_data::compare); + while (char *t = ConfigParser::strtokFile()) { + if (acl_httpstatus_data *q = aclParseHTTPStatusData(t)) + (*curlist)->insert(q, acl_httpstatus_data::compare); } } diff --git a/src/acl/IntRange.cc b/src/acl/IntRange.cc index 3bd8b11c3a..8d471b7002 100644 --- a/src/acl/IntRange.cc +++ b/src/acl/IntRange.cc @@ -11,6 +11,7 @@ #include "squid.h" #include "acl/IntRange.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "fatal.h" #include "Parsing.h" @@ -18,9 +19,7 @@ void ACLIntRange::parse() { - char *a; - - while ((a = strtokFile())) { + while (char *a = ConfigParser::strtokFile()) { char *b = strchr(a, '-'); unsigned short port1, port2; diff --git a/src/acl/Ip.cc b/src/acl/Ip.cc index adcfb48269..d0108af0bd 100644 --- a/src/acl/Ip.cc +++ b/src/acl/Ip.cc @@ -12,6 +12,7 @@ #include "acl/Checklist.h" #include "acl/Ip.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "ip/tools.h" #include "MemBuf.h" @@ -478,7 +479,7 @@ ACLIP::parse() flags.parseFlags(); - while (char *t = strtokFile()) { + while (char *t = ConfigParser::strtokFile()) { acl_ip_data *q = acl_ip_data::FactoryParse(t); while (q != NULL) { diff --git a/src/acl/MaxConnection.cc b/src/acl/MaxConnection.cc index 15bc46dcb2..ca2d0b7d3f 100644 --- a/src/acl/MaxConnection.cc +++ b/src/acl/MaxConnection.cc @@ -11,7 +11,6 @@ #include "squid.h" #include "acl/FilledChecklist.h" #include "acl/MaxConnection.h" -#include "cache_cf.h" #include "client_db.h" #include "Debug.h" #include "SquidConfig.h" @@ -52,7 +51,7 @@ ACLMaxConnection::valid () const void ACLMaxConnection::parse() { - char *t = strtokFile(); + char *t = ConfigParser::strtokFile(); if (!t) return; @@ -62,7 +61,7 @@ ACLMaxConnection::parse() /* suck out file contents */ // ignore comments bool ignore = false; - while ((t = strtokFile())) { + while ((t = ConfigParser::strtokFile())) { ignore |= (*t != '#'); if (ignore) diff --git a/src/acl/MethodData.cc b/src/acl/MethodData.cc index 0d3fcdd800..857bbba329 100644 --- a/src/acl/MethodData.cc +++ b/src/acl/MethodData.cc @@ -11,7 +11,7 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/MethodData.h" -#include "cache_cf.h" +#include "ConfigParser.h" #include "http/RequestMethod.h" int ACLMethodData::ThePurgeCount = 0; @@ -54,7 +54,7 @@ ACLMethodData::dump() const void ACLMethodData::parse() { - while (char *t = strtokFile()) { + while (char *t = ConfigParser::strtokFile()) { HttpRequestMethod m; m.HttpRequestMethodXXX(t); values.push_back(m); diff --git a/src/acl/NoteData.cc b/src/acl/NoteData.cc index c54e6e0440..f81de96b80 100644 --- a/src/acl/NoteData.cc +++ b/src/acl/NoteData.cc @@ -11,7 +11,6 @@ #include "acl/Checklist.h" #include "acl/NoteData.h" #include "acl/StringData.h" -#include "cache_cf.h" #include "ConfigParser.h" #include "Debug.h" #include "HttpRequest.h" @@ -77,7 +76,7 @@ ACLNoteData::dump() const void ACLNoteData::parse() { - char* t = strtokFile(); + char* t = ConfigParser::strtokFile(); assert (t != NULL); name = t; values->parse(); diff --git a/src/acl/ProtocolData.cc b/src/acl/ProtocolData.cc index 7f632ff161..245c23366a 100644 --- a/src/acl/ProtocolData.cc +++ b/src/acl/ProtocolData.cc @@ -11,7 +11,7 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/ProtocolData.h" -#include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "wordlist.h" @@ -53,7 +53,7 @@ ACLProtocolData::dump() const void ACLProtocolData::parse() { - while (char *t = strtokFile()) { + while (char *t = ConfigParser::strtokFile()) { int p = AnyP::PROTO_NONE; for (; p < AnyP::PROTO_UNKNOWN; ++p) { if (strcasecmp(t, AnyP::ProtocolType_str[p]) == 0) { diff --git a/src/acl/Random.cc b/src/acl/Random.cc index 9773e9b149..45fd0b2b4d 100644 --- a/src/acl/Random.cc +++ b/src/acl/Random.cc @@ -9,10 +9,8 @@ /* DEBUG: section 28 Access Control */ #include "squid.h" - #include "acl/FilledChecklist.h" #include "acl/Random.h" -#include "cache_cf.h" #include "Debug.h" #include "Parsing.h" #include "wordlist.h" @@ -60,10 +58,9 @@ ACLRandom::valid() const void ACLRandom::parse() { - char *t; char bufa[256], bufb[256]; - t = strtokFile(); + char *t = ConfigParser::strtokFile(); if (!t) { debugs(28, DBG_PARSE_NOTE(DBG_IMPORTANT), "ACL random missing pattern"); return; diff --git a/src/acl/SslErrorData.cc b/src/acl/SslErrorData.cc index 5c0ebc679f..b42bd6ce27 100644 --- a/src/acl/SslErrorData.cc +++ b/src/acl/SslErrorData.cc @@ -9,7 +9,6 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/SslErrorData.h" -#include "cache_cf.h" #include "wordlist.h" ACLSslErrorData::ACLSslErrorData() : values (NULL) @@ -58,10 +57,9 @@ void ACLSslErrorData::parse() { Ssl::Errors **Tail; - char *t = NULL; for (Tail = &values; *Tail; Tail = &((*Tail)->next)); - while ((t = strtokFile())) { + while (char *t = ConfigParser::strtokFile()) { Ssl::Errors *q = Ssl::ParseErrorString(t); *(Tail) = q; Tail = &q->tail()->next; diff --git a/src/acl/StringData.cc b/src/acl/StringData.cc index 59a03f233b..9432f54202 100644 --- a/src/acl/StringData.cc +++ b/src/acl/StringData.cc @@ -11,7 +11,7 @@ #include "squid.h" #include "acl/Checklist.h" #include "acl/StringData.h" -#include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues) @@ -50,8 +50,7 @@ ACLStringData::dump() const void ACLStringData::parse() { - char *t; - while ((t = strtokFile())) + while (const char *t = ConfigParser::strtokFile()) stringValues.insert(SBuf(t)); } diff --git a/src/acl/TimeData.cc b/src/acl/TimeData.cc index 3a9cabb0df..484b61aee1 100644 --- a/src/acl/TimeData.cc +++ b/src/acl/TimeData.cc @@ -12,6 +12,7 @@ #include "acl/Checklist.h" #include "acl/TimeData.h" #include "cache_cf.h" +#include "ConfigParser.h" #include "Debug.h" #include "wordlist.h" @@ -108,9 +109,7 @@ ACLTimeData::parse() int h1, m1, h2, m2; - char *t = NULL; - - while ((t = strtokFile())) { + while (char *t = ConfigParser::strtokFile()) { if (*t < '0' || *t > '9') { /* assume its day-of-week spec */ diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 9fda772104..b09fc7783e 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -4040,12 +4040,6 @@ requirePathnameExists(const char *name, const char *path) } } -char * -strtokFile(void) -{ - return ConfigParser::strtokFile(); -} - #include "AccessLogEntry.h" /** diff --git a/src/cache_cf.h b/src/cache_cf.h index 4a17e8fa20..32de019fc0 100644 --- a/src/cache_cf.h +++ b/src/cache_cf.h @@ -24,7 +24,6 @@ void parse_eol(char *volatile *var); void parse_wordlist(wordlist ** list); void requirePathnameExists(const char *name, const char *path); void parse_time_t(time_t * var); -char *strtokFile(void); #endif /* SQUID_CACHE_CF_H_ */ diff --git a/src/external_acl.cc b/src/external_acl.cc index 178bbc0117..6c51582b31 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -632,8 +632,6 @@ free_external_acl_data(void *data) void ACLExternal::parse() { - char *token; - if (data) self_destruct(); @@ -641,7 +639,7 @@ ACLExternal::parse() data = cbdataAlloc(external_acl_data); - token = strtokFile(); + char *token = ConfigParser::strtokFile(); if (!token) self_destruct(); @@ -655,7 +653,7 @@ ACLExternal::parse() // this is the name of the 'acl' directive being tested data->name = xstrdup(AclMatchedName); - while ((token = strtokFile())) { + while ((token = ConfigParser::strtokFile())) { wordlistAdd(&data->arguments, token); } } diff --git a/src/tests/stub_cache_cf.cc b/src/tests/stub_cache_cf.cc index 415f8be820..128c221d77 100644 --- a/src/tests/stub_cache_cf.cc +++ b/src/tests/stub_cache_cf.cc @@ -17,6 +17,7 @@ #define STUB_API "cache_cf.cc" #include "tests/STUB.h" +#include "cache_cf.h" void self_destruct(void) STUB void parse_int(int *var) STUB void parse_onoff(int *var) STUB @@ -24,7 +25,6 @@ void parse_eol(char *volatile *var) STUB void parse_wordlist(wordlist ** list) STUB void requirePathnameExists(const char *name, const char *path) STUB_NOP void parse_time_t(time_t * var) STUB -char * strtokFile(void) STUB_RETVAL(NULL) void ConfigParser::ParseUShort(unsigned short *var) STUB void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head) STUB void dump_acl_list(StoreEntry*, ACLList*) STUB