Added extra parameter to config clearKey() method used to clear key(s) matching a given value.
git-svn-id: http://voip.null.ro/svn/yate@6563 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
21d6241621
commit
d43863899a
|
@ -3908,7 +3908,7 @@ void* JsConfigFile::getObject(const String& name) const
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleCfgSetValues(bool set, Configuration& cfg, const String& sName,
|
static inline void handleCfgSetValues(bool set, Configuration& cfg, const String& sName,
|
||||||
GenObject* params, const String* prefix)
|
GenObject* params, const String* prefix)
|
||||||
{
|
{
|
||||||
const NamedList* pList = sName ? getReplaceParams(params) : 0;
|
const NamedList* pList = sName ? getReplaceParams(params) : 0;
|
||||||
|
@ -3935,6 +3935,20 @@ static void handleCfgSetValues(bool set, Configuration& cfg, const String& sName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void handleCfgClearKey(Configuration& cfg, const String& sName, const String& kName,
|
||||||
|
const String* kVal = 0)
|
||||||
|
{
|
||||||
|
NamedList* sect = cfg.getSection(sName);
|
||||||
|
if (!sect)
|
||||||
|
return;
|
||||||
|
if (kVal) {
|
||||||
|
JsRegExp* r = YOBJECT(JsRegExp,kVal);
|
||||||
|
if (r)
|
||||||
|
kVal = static_cast<const String*>(&r->regexp());
|
||||||
|
}
|
||||||
|
sect->clearParam(kName,0,kVal);
|
||||||
|
}
|
||||||
|
|
||||||
bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||||
{
|
{
|
||||||
XDebug(&__plugin,DebugAll,"JsConfigFile::runNative '%s'(" FMT64 ")",oper.name().c_str(),oper.number());
|
XDebug(&__plugin,DebugAll,"JsConfigFile::runNative '%s'(" FMT64 ")",oper.name().c_str(),oper.number());
|
||||||
|
@ -4101,9 +4115,13 @@ bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject
|
||||||
m_config.clearSection(op ? (const char*)*op : 0);
|
m_config.clearSection(op ? (const char*)*op : 0);
|
||||||
}
|
}
|
||||||
else if (oper.name() == YSTRING("clearKey")) {
|
else if (oper.name() == YSTRING("clearKey")) {
|
||||||
if (extractArgs(stack,oper,context,args) != 2)
|
// clearKey(sect,key[,matchValue])
|
||||||
|
ExpOperation* sect = 0;
|
||||||
|
ExpOperation* key = 0;
|
||||||
|
ExpOperation* matchValue = 0;
|
||||||
|
if (!extractStackArgs(2,this,stack,oper,context,args,§,&key,&matchValue))
|
||||||
return false;
|
return false;
|
||||||
m_config.clearKey(*static_cast<ExpOperation*>(args[0]),*static_cast<ExpOperation*>(args[1]));
|
handleCfgClearKey(m_config,*sect,*key,matchValue);
|
||||||
}
|
}
|
||||||
else if (oper.name() == YSTRING("keys")) {
|
else if (oper.name() == YSTRING("keys")) {
|
||||||
if (extractArgs(stack,oper,context,args) != 1)
|
if (extractArgs(stack,oper,context,args) != 1)
|
||||||
|
@ -4271,11 +4289,12 @@ bool JsConfigSection::runNative(ObjList& stack, const ExpOperation& oper, GenObj
|
||||||
handleCfgSetValues(oper.name() == YSTRING("setValues"),m_owner->config(),toString(),params,prefix);
|
handleCfgSetValues(oper.name() == YSTRING("setValues"),m_owner->config(),toString(),params,prefix);
|
||||||
}
|
}
|
||||||
else if (oper.name() == YSTRING("clearKey")) {
|
else if (oper.name() == YSTRING("clearKey")) {
|
||||||
if (extractArgs(stack,oper,context,args) != 1)
|
// clearKey(key[,matchValue])
|
||||||
|
ExpOperation* key = 0;
|
||||||
|
ExpOperation* matchValue = 0;
|
||||||
|
if (!extractStackArgs(1,this,stack,oper,context,args,&key,&matchValue))
|
||||||
return false;
|
return false;
|
||||||
NamedList* sect = m_owner->config().getSection(toString());
|
handleCfgClearKey(m_owner->config(),toString(),*key,matchValue);
|
||||||
if (sect)
|
|
||||||
sect->clearParam(*static_cast<ExpOperation*>(args[0]));
|
|
||||||
}
|
}
|
||||||
else if (oper.name() == YSTRING("keys")) {
|
else if (oper.name() == YSTRING("keys")) {
|
||||||
if (extractArgs(stack,oper,context,args) != 0)
|
if (extractArgs(stack,oper,context,args) != 0)
|
||||||
|
|
Loading…
Reference in New Issue