From 6f2c70aa866afde441044c6cea81c2a65985d2d0 Mon Sep 17 00:00:00 2001 From: paulc Date: Mon, 23 Jul 2007 16:18:18 +0000 Subject: [PATCH] Added support for multiple module directories, can be specified from the command line. git-svn-id: http://yate.null.ro/svn/yate/trunk@1405 acf43c95-373e-0410-b603-e72c3f656dc1 --- clients/main-gtk2.cpp | 2 +- engine/Engine.cpp | 28 ++++++++++++++++++++++------ yate.8 | 6 ++++++ yatengine.h | 10 +++++----- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/clients/main-gtk2.cpp b/clients/main-gtk2.cpp index 81d2c482..6a096418 100644 --- a/clients/main-gtk2.cpp +++ b/clients/main-gtk2.cpp @@ -37,7 +37,7 @@ extern "C" int main(int argc, const char** argv, const char** envp) bool fail = !gtk_init_check(&argc,(char ***)&argv); if (fail) g_warning("Cannot open display: '%s'",gdk_get_display()); - TelEngine::Engine::extraPath() = "gtk2"; + TelEngine::Engine::extraPath("gtk2"); return TelEngine::Engine::main(argc,argv,envp,TelEngine::Engine::Client,fail); } /* vi: set ts=8 sw=4 sts=4 noet: */ diff --git a/engine/Engine.cpp b/engine/Engine.cpp index c85c95da..a8a42419 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -136,8 +136,8 @@ static void sighandler(int signal) String Engine::s_cfgpath(CFG_PATH); String Engine::s_cfgsuffix(CFG_SUFFIX); String Engine::s_modpath(MOD_PATH); -String Engine::s_extramod; String Engine::s_modsuffix(DLL_SUFFIX); +ObjList Engine::s_extramod; Engine::RunMode Engine::s_mode = Engine::Stopped; Engine* Engine::s_self = 0; @@ -863,9 +863,7 @@ void Engine::loadPlugins() const char *name = s_cfg.getValue("general","modpath"); if (name) s_modpath = name; - name = s_cfg.getValue("general","extrapath"); - if (name) - s_extramod = name; + extraPath(s_cfg.getValue("general","extrapath")); s_maxworkers = s_cfg.getIntValue("general","maxworkers",s_maxworkers); s_restarts = s_cfg.getIntValue("general","restarts"); m_dispatcher.warnTime(1000*(u_int64_t)s_cfg.getIntValue("general","warntime")); @@ -879,8 +877,10 @@ void Engine::loadPlugins() } } loadPluginDir(String::empty()); - if (s_extramod) - loadPluginDir(s_extramod); + while (GenObject* extra = s_extramod.remove(false)) { + loadPluginDir(extra->toString()); + extra->destruct(); + } l = s_cfg.getSection("postload"); if (l) { unsigned int len = l->length(); @@ -916,6 +916,13 @@ int Engine::usedPlugins() return used; } +void Engine::extraPath(const String& path) +{ + if (path.null() || s_extramod.find(path)) + return; + s_extramod.append(new String(path)); +} + void Engine::halt(unsigned int code) { if (s_haltcode == -1) @@ -990,6 +997,7 @@ static void usage(bool client, FILE* f) " -n configname Use specified configuration name (%s)\n" " -c pathname Path to conf files directory (" CFG_PATH ")\n" " -m pathname Path to modules directory (" MOD_PATH ")\n" +" -x relpath Relative path to extra modules directory (can be repeated)\n" " -w directory Change working directory\n" #ifdef RLIMIT_CORE " -C Enable core dumps if possible\n" @@ -1176,6 +1184,14 @@ int Engine::main(int argc, const char** argv, const char** env, RunMode mode, bo pc = 0; workdir = argv[++i]; break; + case 'x': + if (i+1 >= argc) { + noarg(client,argv[i]); + return ENOENT; + } + pc = 0; + extraPath(argv[++i]); + break; #ifdef RLIMIT_CORE case 'C': s_coredump = true; diff --git a/yate.8 b/yate.8 index 6c04510b..6dacca72 100644 --- a/yate.8 +++ b/yate.8 @@ -64,6 +64,12 @@ Path to conf files directory, overrides compiled-in value .TP .B \-m \fIpathname\fR Path to modules directory, overrides compiled-in value +.TP +.B \-x \fIrelpath\fR +Relative path to extra modules directory (can be repeated) +.TP +.B \-w \fIdirectory\fR +Change working directory .SS Debugging options (may not be compiled in) .TP .B \-C diff --git a/yatengine.h b/yatengine.h index 7e413659..09b7c424 100644 --- a/yatengine.h +++ b/yatengine.h @@ -781,11 +781,11 @@ public: { return s_modpath; } /** - * The relative extra module loading path. This is empty by default but - * can be set by a main program to a value before calling @ref main() + * Add a relative extra module loading path. The list is empty by default + * but can be filled by a main program before calling @ref main() + * @param path Relative path to extra modules to be loaded */ - inline static String& extraPath() - { return s_extramod; } + static void extraPath(const String& path); /** * Get the module filename suffix @@ -961,8 +961,8 @@ private: static String s_cfgpath; static String s_cfgsuffix; static String s_modpath; - static String s_extramod; static String s_modsuffix; + static ObjList s_extramod; static int s_haltcode; static RunMode s_mode; };