bloacklist for module loading config parameter. allows to exclude some modules from loading

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@574 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent b075f6c03f
commit 823238100b

@ -43,6 +43,7 @@ string AmConfig::SmtpServerAddress = SMTP_ADDRESS_IP;
unsigned int AmConfig::SmtpServerPort = SMTP_PORT;
string AmConfig::PlugInPath = PLUG_IN_PATH;
string AmConfig::LoadPlugins = "";
string AmConfig::ExcludePlugins = "";
int AmConfig::DaemonMode = DEFAULT_DAEMON_MODE;
string AmConfig::LocalIP = "";
string AmConfig::PrefixSep = PREFIX_SEPARATOR;
@ -188,6 +189,9 @@ int AmConfig::readConfiguration()
// load_plugins
LoadPlugins = cfg.getParameter("load_plugins");
// exclude_plugins
ExcludePlugins = cfg.getParameter("exclude_plugins");
// user_agent
if (cfg.getParameter("use_default_signature")=="yes")
Signature = DEFAULT_SIGNATURE;

@ -56,6 +56,8 @@ struct AmConfig
static string PlugInPath;
/** semicolon separated list of plugins to load */
static string LoadPlugins;
/** semicolon separated list of plugins to exclude from loading */
static string ExcludePlugins;
//static unsigned int MaxRecordTime;
/** run the programm in daemon mode? */
static int DaemonMode;

@ -44,6 +44,9 @@
#include <string.h>
#include <errno.h>
#include <set>
using std::set;
static unsigned int pcm16_bytes2samples(long h_codec, unsigned int num_bytes)
{
return num_bytes / 2;
@ -137,13 +140,26 @@ int AmPlugIn::load(const string& directory, const string& plugins)
if (!plugins.length()) {
DBG("AmPlugIn: loading modules in directory '%s':\n", directory.c_str());
while( ((entry = readdir(dir)) != NULL) && (err == 0) ){
vector<string> excluded_plugins = explode(AmConfig::ExcludePlugins, ";");
set<string> excluded_plugins_s;
for (vector<string>::iterator it = excluded_plugins.begin();
it != excluded_plugins.end();it++)
excluded_plugins_s.insert(*it);
string plugin_file = directory + "/" + string(entry->d_name);
while( ((entry = readdir(dir)) != NULL) && (err == 0) ){
string plugin_name = string(entry->d_name);
if( plugin_file.find(".so",plugin_file.length()-3) == string::npos ){
if(plugin_name.find(".so",plugin_name.length()-3) == string::npos ){
continue;
}
if (excluded_plugins_s.find(plugin_name.substr(0, plugin_name.length()-3))
!= excluded_plugins_s.end()) {
DBG("skipping excluded plugin %s\n", plugin_name.c_str());
continue;
}
string plugin_file = directory + "/" + plugin_name;
DBG("loading %s ...\n",plugin_file.c_str());
if( (err = loadPlugIn(plugin_file)) < 0 ) {
@ -578,7 +594,7 @@ int AmPlugIn::loadCtrlFacPlugIn(AmPluginFactory* f)
return -1;
}
if (ctrlIface) {
ERROR("once control interface already loaded (`%s'): can not load a "
ERROR("one control interface already loaded (`%s'): can not load a "
"second one (`%s').\n", (ctrlIface->getName()).c_str(),
(_ctrlIface->getName()).c_str());
return -1;

@ -77,6 +77,14 @@ plugin_path=/usr/local/lib/sems/plug-in/
# example for announcement with g711 and ilbc codecs only
# load_plugins=wav;ilbc;announcement
# optional parameter: exclude_plugins=<modules list>
#
# semicolon-separated list of modules to exclude from loading
# ('blacklist'). This has only effect it load_plugins is empty.
# If empty, all modules in plugin_path are loaded.
#
exclude_plugins=binrpcctrl;
# optional parameter: smtp_server=<hostname>
#
# - sets address of smtp server

Loading…
Cancel
Save