[sr-dev] git:master: modules/app_lua: Updated app_lua to support URI lookup in registrar
Peter Dunkley
peter.dunkley at crocodile-rcs.com
Sat Dec 22 00:10:35 CET 2012
Module: sip-router
Branch: master
Commit: 72bee685f57ccd0637e1bc97093c9e5731c2d40f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=72bee685f57ccd0637e1bc97093c9e5731c2d40f
Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date: Fri Dec 21 23:10:05 2012 +0000
modules/app_lua: Updated app_lua to support URI lookup in registrar
- Enhancement added by Hugh Waite @ Crocodile RCS
---
modules/app_lua/app_lua_exp.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/modules/app_lua/app_lua_exp.c b/modules/app_lua/app_lua_exp.c
index 856bc0d..fad9864 100644
--- a/modules/app_lua/app_lua_exp.c
+++ b/modules/app_lua/app_lua_exp.c
@@ -1313,7 +1313,8 @@ static int lua_sr_registrar_save(lua_State *L)
static int lua_sr_registrar_lookup(lua_State *L)
{
int ret;
- char *table;
+ char *table = NULL;
+ str uri = {NULL, 0};
sr_lua_env_t *env_L;
env_L = sr_lua_env_get();
@@ -1328,18 +1329,31 @@ static int lua_sr_registrar_lookup(lua_State *L)
LM_WARN("invalid parameters from Lua env\n");
return app_lua_return_error(L);
}
- if(lua_gettop(L)!=1)
+ if(lua_gettop(L)==1)
+ {
+ table = (char*)lua_tostring(L, -1);
+ }
+ else if (lua_gettop(L)==2)
+ {
+ table = (char*)lua_tostring(L, -2);
+ uri.s = (char*)lua_tostring(L, -1);
+ uri.len = strlen(uri.s);
+ } else
{
LM_WARN("invalid number of parameters from Lua\n");
return app_lua_return_error(L);
}
- table = (char*)lua_tostring(L, -1);
if(table==NULL || strlen(table)==0)
{
LM_WARN("invalid parameters from Lua\n");
return app_lua_return_error(L);
}
- ret = _lua_registrarb.lookup(env_L->msg, table);
+ if(lua_gettop(L)==2)
+ {
+ ret = _lua_registrarb.lookup_uri(env_L->msg, table, &uri);
+ } else {
+ ret = _lua_registrarb.lookup(env_L->msg, table);
+ }
return app_lua_return_int(L, ret);
}
More information about the sr-dev
mailing list