return false;
}
vector<string> parts;
- vector<string>::const_iterator i;
stringtok( parts, param->second, ", \t" );
- for( i = parts.begin(); i != parts.end(); i++ ) {
- if( *i == val ) {
+ for (const auto& part: parts) {
+ if (part == val) {
return true;
}
}
prefix="";
string help;
-
- for(map<string,string>::const_iterator i=helpmap.begin();
- i!=helpmap.end();
- i++)
- {
- if(!prefix.empty() && i->first.find(prefix)) // only print items with prefix
- continue;
+
+ for (const auto& i: helpmap) {
+ if(!prefix.empty() && i.first.find(prefix) != 0) // only print items with prefix
+ continue;
help+=" --";
- help+=i->first;
+ help+=i.first;
- string type=d_typeMap[i->first];
+ string type=d_typeMap[i.first];
if(type=="Parameter")
help+="=...";
else if(type=="Switch")
{
- help+=" | --"+i->first+"=yes";
- help+=" | --"+i->first+"=no";
+ help+=" | --"+i.first+"=yes";
+ help+=" | --"+i.first+"=no";
}
help+="\n\t";
- help+=i->second;
+ help+=i.second;
help+="\n";
}
else
help="# Autogenerated configuration file template\n";
- for(map<string,string>::const_iterator i=helpmap.begin(); i!=helpmap.end(); i++) {
- if(d_typeMap[i->first]=="Command")
+ for(const auto& i: helpmap) {
+ if(d_typeMap[i.first]=="Command")
continue;
help+="#################################\n";
help+="# ";
- help+=i->first;
+ help+=i.first;
help+="\t";
- help+=i->second;
+ help+=i.second;
help+="\n#\n";
if (current) {
- help+=i->first+"="+params[i->first]+"\n\n";
+ help+=i.first+"="+params[i.first]+"\n\n";
} else {
- help+="# "+i->first+"="+params[i->first]+"\n\n";
+ help+="# "+i.first+"="+params[i.first]+"\n\n";
}
}
return help;
string::size_type pos;
bool incremental = false;
- if(!arg.find("--") && (pos=arg.find("+="))!=string::npos) // this is a --port+=25 case
+ if(arg.find("--") == 0 && (pos=arg.find("+="))!=string::npos) // this is a --port+=25 case
{
var=arg.substr(2,pos-2);
val=arg.substr(pos+2);
incremental = true;
}
- else if(!arg.find("--") && (pos=arg.find("="))!=string::npos) // this is a --port=25 case
+ else if(arg.find("--") == 0 && (pos=arg.find("="))!=string::npos) // this is a --port=25 case
{
var=arg.substr(2,pos-2);
val=arg.substr(pos+1);
}
- else if(!arg.find("--") && (arg.find("=")==string::npos)) // this is a --daemon case
+ else if(arg.find("--") == 0 && (arg.find("=")==string::npos)) // this is a --daemon case
{
var=arg.substr(2);
val="";
{
for(int n=1;n<argc;n++) {
string varval=argv[n];
- if(!varval.find("--"+arg))
+ if(varval.find("--"+arg) == 0)
parseOne(argv[n]);
}
}
set("include-dir","Directory to include configuration files from");
if(!parseFile(fname, "", lax)) {
- L << Logger::Warning << "Unable to open " << fname << std::endl;
+ g_log << Logger::Warning << "Unable to open " << fname << std::endl;
return false;
}
gatherIncludes(extraConfigs);
for(const std::string& fn : extraConfigs) {
if (!file(fn.c_str(), lax, true)) {
- L << Logger::Error << fn << " could not be parsed" << std::endl;
+ g_log << Logger::Error << fn << " could not be parsed" << std::endl;
throw ArgException(fn + " could not be parsed");
}
}
// stat
if (stat(params["include-dir"].c_str(), &st)) {
- L << Logger::Error << params["include-dir"] << " does not exist!" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " does not exist!" << std::endl;
throw ArgException(params["include-dir"] + " does not exist!");
}
// wonder if it's accessible directory
if (!S_ISDIR(st.st_mode)) {
- L << Logger::Error << params["include-dir"] << " is not a directory" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " is not a directory" << std::endl;
throw ArgException(params["include-dir"] + " is not a directory");
}
if (!(dir = opendir(params["include-dir"].c_str()))) {
- L << Logger::Error << params["include-dir"] << " is not accessible" << std::endl;
+ g_log << Logger::Error << params["include-dir"] << " is not accessible" << std::endl;
throw ArgException(params["include-dir"] + " is not accessible");
}
namebuf << params["include-dir"].c_str() << "/" << ent->d_name; // FIXME: Use some path separator
// ensure it's readable file
if (stat(namebuf.str().c_str(), &st) || !S_ISREG(st.st_mode)) {
- L << Logger::Error << namebuf.str() << " is not a file" << std::endl;
+ g_log << Logger::Error << namebuf.str() << " is not a file" << std::endl;
closedir(dir);
throw ArgException(namebuf.str() + " does not exist!");
}