From 3fcfa79874045bd8c3c03cfd3aea5ceda8d0a3fd Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 28 Oct 2012 03:54:40 -0600 Subject: [PATCH] Remove 'Bungled' warning on missing component directives * Make Squid display a ERROR notice and ignore squid.conf directives which belong to components disabled at build time instead of throwing up 'FATAL: Bungled' message and aborting. * Polish the 'requires X' message text for better display of cases like 'requires MS Windows' and 'requires Linux' * Add 'requires X' message for --enable-auth, --enable-eui, and --enable-ssl-crtd which were missing. * Add debug 'filename' for if-none and postscriptum logging --- src/cf_gen.cc | 22 ++++++++++++++-------- src/cf_gen_defines | 7 +++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/cf_gen.cc b/src/cf_gen.cc index c04dfa4eda..2f38c7a128 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -151,6 +151,7 @@ static void gen_dump(const EntryList &, std::ostream&); static void gen_free(const EntryList &, std::ostream&); static void gen_conf(const EntryList &, std::ostream&, bool verbose_output); static void gen_default_if_none(const EntryList &, std::ostream&); +static const char *available_if(const std::string &name); static void checkDepend(const std::string &directive, const char *name, const TypeList &types, const EntryList &entries) @@ -520,7 +521,9 @@ gen_default_if_none(const EntryList &head, std::ostream &fout) { fout << "static void" << std::endl << "defaults_if_none(void)" << std::endl << - "{" << std::endl; + "{" << std::endl << + " cfg_filename = \"Default Configuration (if absent)\";" << std::endl << + " config_lineno = 0;" << std::endl; for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) { assert(entry->name.size()); @@ -548,13 +551,16 @@ gen_default_if_none(const EntryList &head, std::ostream &fout) fout << "#endif" << std::endl; } - fout << "}" << std::endl << std::endl; + fout << " cfg_filename = NULL;" << std::endl << + "}" << std::endl << std::endl; } void Entry::genParseAlias(const std::string &aName, std::ostream &fout) const { fout << " if (!strcmp(token, \"" << aName << "\")) {" << std::endl; + if (ifdef.size()) + fout << "#if " << ifdef << std::endl; fout << " "; if (type.compare("obsolete") == 0) { fout << "debugs(0, DBG_CRITICAL, \"ERROR: Directive '" << aName << "' is obsolete.\");\n"; @@ -569,6 +575,12 @@ Entry::genParseAlias(const std::string &aName, std::ostream &fout) const fout << "parse_" << type << "(&" << loc << (array_flag ? "[0]" : "") << ");"; } fout << std::endl; + if (ifdef.size()) { + fout << + "#else" << std::endl << + " debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), \"ERROR: '" << name << "' requires " << available_if(ifdef) << "\");" << std::endl << + "#endif" << std::endl; + } fout << " return 1;" << std::endl; fout << " };" << std::endl; } @@ -579,9 +591,6 @@ Entry::genParse(std::ostream &fout) const if (name.compare("comment") == 0) return; - if (ifdef.size()) - fout << "#if " << ifdef << std::endl; - // Once for the current directive name genParseAlias(name, fout); @@ -589,9 +598,6 @@ Entry::genParse(std::ostream &fout) const for (EntryAliasList::const_iterator a = alias.begin(); a != alias.end(); ++a) { genParseAlias(*a, fout); } - - if (ifdef.size()) - fout << "#endif\n"; } static void diff --git a/src/cf_gen_defines b/src/cf_gen_defines index c430bbb1b9..0c9bc28c80 100644 --- a/src/cf_gen_defines +++ b/src/cf_gen_defines @@ -14,6 +14,7 @@ BEGIN { define["ICAP_CLIENT"]="--enable-icap-client" define["SQUID_SNMP"]="--enable-snmp" define["USE_ADAPTATION"]="--enable-ecap or --enable-icap-client" + define["USE_AUTH"]="--enable-auth" define["USE_CACHE_DIGESTS"]="--enable-cache-digests" define["USE_DNSHELPER"]="--disable-internal-dns" define["!USE_DNSHELPER"]="--enable-internal-dns" @@ -24,6 +25,8 @@ BEGIN { define["USE_IDENT"]="--enable-ident-lookups" define["USE_LOADABLE_MODULES"]="--enable-loadable-modules" define["USE_SQUID_ESI"]="--enable-esi" + define["USE_SQUID_EUI"]="--enable-eui" + define["USE_SSL_CRTD"]="--enable-ssl-crtd" define["USE_SSL"]="--enable-ssl" define["USE_UNLINKD"]="--enable-unlinkd" define["USE_WCCP"]="--enable-wccp" @@ -34,8 +37,8 @@ BEGIN { } /^IFDEF:/ { if (define[$2] != "") - DEFINE=define[$2] " option" - else + DEFINE=define[$2] + else DEFINE="-D" $2 " define" print "{\"" $2 "\", \"" DEFINE "\", " print "#if " $2 -- 2.47.2