Browse Source

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

Daniel-Constantin Mierla 15 years ago
parent
commit
e15ef08898
2 changed files with 25 additions and 3 deletions
  1. 21 3
      modules/app_lua/app_lua_api.c
  2. 4 0
      modules/app_lua/app_lua_api.h

+ 21 - 3
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)
 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
 	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;
 	return 1;
 }
 }
 
 

+ 4 - 0
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,
 int app_lua_run(struct sip_msg *msg, char *func, char *p1, char *p2,
 		char *p3);
 		char *p3);
 
 
+#define SRLUA_FALSE	0
+#define SRLUA_TRUE	1
 int app_lua_return_boolean(lua_State *L, int b);
 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);
 void app_lua_dump_stack(lua_State *L);