From b8a7bf58c974c9ba4518fd894963cd66a19baf7e Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Mon, 16 May 2011 19:18:00 +0200 Subject: [PATCH] [trac922] Using a parameter to distinguish filename --- src/lib/config/ccsession.cc | 5 +++-- src/lib/config/ccsession.h | 11 ++++++----- src/lib/config/tests/ccsession_unittests.cc | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 3cf38e3d30..45710e35ec 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -358,11 +358,12 @@ ModuleCCSession::checkCommand() { std::string ModuleCCSession::addRemoteConfig(const std::string& spec_name, void (*handler)(const std::string& module, - ConstElementPtr)) + ConstElementPtr), + bool spec_is_filename) { std::string module_name; ModuleSpec rmod_spec; - if (spec_name.find_first_of("./") != std::string::npos) { + if (spec_is_filename) { // It's a file name, so load it rmod_spec = readModuleSpecification(spec_name); module_name = diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 5c21ba0d0f..efc8e6f324 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -244,22 +244,23 @@ public: * filename of the spec file to use or a name of module * (in case it's a module name, the spec data is * downloaded from the configuration manager, therefore - * the configuration manager must know it). A heuristic - * is used to guess which should be used - if it contains - * a slash or dot, filename is assumed, otherwise - * name of module is assumed. + * the configuration manager must know it). If + * spec_is_filenabe is true (the default), then a + * filename is assumed, otherwise a module name. * \param handler The handler function called whenever there's a change. * Called once initally from this function. May be NULL * if you don't want any handler to be called and you're * fine with requesting the data through * getRemoteConfigValue() each time. + * \param spec_is_filename Says if spec_name is filename or module name. * \return The name of the module specified in the given specification * file */ std::string addRemoteConfig(const std::string& spec_name, void (*handler)(const std::string& module_name, isc::data::ConstElementPtr - update) = NULL); + update) = NULL, + bool spec_is_filename = true); /** * Removes the module with the given name from the remote config diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index bce3e51c9f..3564d4bfd1 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -412,7 +412,8 @@ TEST_F(CCSessionTest, remoteConfig) { session.getMessages()->add(createAnswer(0, spec.getFullSpec())); session.getMessages()->add(createAnswer(0, el("{}"))); - EXPECT_NO_THROW(module_name = mccs.addRemoteConfig("Spec2")); + EXPECT_NO_THROW(module_name = mccs.addRemoteConfig("Spec2", NULL, + false)); EXPECT_EQ("Spec2", module_name); EXPECT_NO_THROW(item1 =