diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 307529f4..c026c5eb 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -269,19 +269,35 @@ bool RclConfig::getConfParam(const std::string &name, bool *bvp) return true; } +bool RclConfig::getConfParam(const std::string &name, vector *svvp) +{ + if (!svvp) + return false; + svvp->clear(); + string s; + if (!getConfParam(name, s)) + return false; + return stringToStrings(s, *svvp); +} +bool RclConfig::getConfParam(const std::string &name, list *svvp) +{ + if (!svvp) + return false; + svvp->clear(); + string s; + if (!getConfParam(name, s)) + return false; + return stringToStrings(s, *svvp); +} + list RclConfig::getTopdirs() { list tdl; - // Retrieve the list of directories to be indexed. - string topdirs; - if (!getConfParam("topdirs", topdirs)) { - LOGERR(("RclConfig::getTopdirs: no top directories in config\n")); - return tdl; - } - if (!stringToStrings(topdirs, tdl)) { - LOGERR(("RclConfig::getTopdirs: parse error for directory list\n")); + if (!getConfParam("topdirs", &tdl)) { + LOGERR(("RclConfig::getTopdirs: no top directories in config or bad list format\n")); return tdl; } + for (list::iterator it = tdl.begin(); it != tdl.end(); it++) { *it = path_tildexpand(*it); *it = path_canon(*it); @@ -807,10 +823,8 @@ list& RclConfig::getSkippedNames() list RclConfig::getSkippedPaths() { list skpl; - string skipped; - if (getConfParam("skippedPaths", skipped)) { - stringToStrings(skipped, skpl); - } + getConfParam("skippedPaths", &skpl); + // Always add the dbdir and confdir to the skipped paths. This is // especially important for the rt monitor which will go into a loop if we // don't do this. @@ -830,10 +844,7 @@ list RclConfig::getDaemSkippedPaths() list skpl = getSkippedPaths(); list dskpl; - string skipped; - if (getConfParam("daemSkippedPaths", skipped)) { - stringToStrings(skipped, dskpl); - } + getConfParam("daemSkippedPaths", &dskpl); for (list::iterator it = dskpl.begin(); it != dskpl.end(); it++) { *it = path_tildexpand(*it); diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index cac1087a..dd925bea 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -97,9 +97,13 @@ class RclConfig { return m_conf->get(name, value, m_keydir); } /** Variant with autoconversion to int */ - bool getConfParam(const std::string &name, int *value); + bool getConfParam(const string &name, int *value); /** Variant with autoconversion to bool */ - bool getConfParam(const std::string &name, bool *value); + bool getConfParam(const string &name, bool *value); + /** Variant with conversion to string list/vector + * (stringToStrings). Can fail if the string is malformed. */ + bool getConfParam(const string &name, vector *value); + bool getConfParam(const string &name, list *value); /** * Get list of config names under current sk, with possible