diff --git a/src/ConfigParser.cc b/src/ConfigParser.cc index 6dfa92f3cfd..25e0c09f73c 100644 --- a/src/ConfigParser.cc +++ b/src/ConfigParser.cc @@ -34,6 +34,13 @@ bool ConfigParser::PreviewMode_ = false; static const char *SQUID_ERROR_TOKEN = "[invalid token]"; +ConfigParser & +Configuration::LegacyParser() +{ + static ConfigParser *instance = new ConfigParser(); + return *instance; +} + void ConfigParser::destruct() { diff --git a/src/ConfigParser.h b/src/ConfigParser.h index d464b890fb8..4ca97986a7a 100644 --- a/src/ConfigParser.h +++ b/src/ConfigParser.h @@ -235,6 +235,16 @@ class ConfigParser namespace Configuration { /// interprets (and partially applies) squid.conf or equivalent configuration void Parse(); + +/** + * A parser for legacy code that uses the global approach. + * Only valid when parsing squid.conf. + * + * Deprecated; code needing access to a ConfigParser should + * have it provided to them in their parseFoo() methods. + */ +ConfigParser &LegacyParser(); + } #endif /* SQUID_SRC_CONFIGPARSER_H */ diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 4942f479bd2..2c4f397521d 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -260,11 +260,11 @@ static void free_http_upgrade_request_protocols(HttpUpgradeProtocolAccess **prot /* * LegacyParser is a parser for legacy code that uses the global - * approach. This is static so that it is only exposed to cache_cf. - * Other modules needing access to a ConfigParser should have it - * provided to them in their parserFOO methods. + * approach. + * Deprecated; other modules needing access to a ConfigParser should + * have it provided to them in their parseFoo() methods. */ -static ConfigParser LegacyParser = ConfigParser(); +static auto LegacyParser = Configuration::LegacyParser(); const char *cfg_directive = nullptr; const char *cfg_filename = nullptr;