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
This commit is contained in:
paulc 2007-07-23 16:18:18 +00:00
parent 8cc4f40ab4
commit 6f2c70aa86
4 changed files with 34 additions and 12 deletions

View File

@ -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: */

View File

@ -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;

6
yate.8
View File

@ -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

View File

@ -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;
};