[sr-dev] git:master: app_lua: added helper functions to return true/false to Lua

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 15 19:43:31 CET 2010


Module: sip-router
Branch: master
Commit: e15ef088980a6d6898a6a93b872fa620fab85d42
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e15ef088980a6d6898a6a93b872fa620fab85d42

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Nov 15 19:36:25 2010 +0100

app_lua: added helper functions to return true/false to Lua

---

 modules/app_lua/app_lua_api.c |   24 +++++++++++++++++++++---
 modules/app_lua/app_lua_api.h |    4 ++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/modules/app_lua/app_lua_api.c b/modules/app_lua/app_lua_api.c
index 1673f5e..c4bdfea 100644
--- a/modules/app_lua/app_lua_api.c
+++ b/modules/app_lua/app_lua_api.c
@@ -276,10 +276,28 @@ int lua_sr_initialized(void)
  */
 int app_lua_return_boolean(lua_State *L, int b)
 {
-	if(b==0)
-		lua_pushboolean(L, 0);
+	if(b==SRLUA_FALSE)
+		lua_pushboolean(L, SRLUA_FALSE);
 	else
-		lua_pushboolean(L, 1);
+		lua_pushboolean(L, SRLUA_TRUE);
+	return 1;
+}
+
+/**
+ *
+ */
+int app_lua_return_false(lua_State *L)
+{
+	lua_pushboolean(L, SRLUA_FALSE);
+	return 1;
+}
+
+/**
+ *
+ */
+int app_lua_return_true(lua_State *L)
+{
+	lua_pushboolean(L, SRLUA_TRUE);
 	return 1;
 }
 
diff --git a/modules/app_lua/app_lua_api.h b/modules/app_lua/app_lua_api.h
index 51ebc15..a813a91 100644
--- a/modules/app_lua/app_lua_api.h
+++ b/modules/app_lua/app_lua_api.h
@@ -55,7 +55,11 @@ int app_lua_runstring(struct sip_msg *msg, char *script);
 int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2,
 		char *p3);
 
+#define SRLUA_FALSE	0
+#define SRLUA_TRUE	1
 int app_lua_return_boolean(lua_State *L, int b);
+int app_lua_return_false(lua_State *L);
+int app_lua_return_true(lua_State *L);
 
 void app_lua_dump_stack(lua_State *L);
 




More information about the sr-dev mailing list