[asterisk-commits] qwell: trunk r89124 - /trunk/pbx/pbx_lua.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Nov 8 17:38:30 CST 2007
Author: qwell
Date: Thu Nov 8 17:38:30 2007
New Revision: 89124
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89124
Log:
Add check_hangup() method to pbx_lua, which can be used to check whether it is time to hangup a channel.
Closes issue #11202, patch by mnicholson
Modified:
trunk/pbx/pbx_lua.c
Modified: trunk/pbx/pbx_lua.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_lua.c?view=diff&rev=89124&r1=89123&r2=89124
==============================================================================
--- trunk/pbx/pbx_lua.c (original)
+++ trunk/pbx/pbx_lua.c Thu Nov 8 17:38:30 2007
@@ -73,6 +73,7 @@
static int lua_autoservice_start(lua_State *L);
static int lua_autoservice_stop(lua_State *L);
static int lua_autoservice_status(lua_State *L);
+static int lua_check_hangup(lua_State *L);
static void lua_update_registry(lua_State *L, const char *context, const char *exten, int priority);
static void lua_push_variable_table(lua_State *L, const char *name);
@@ -81,6 +82,7 @@
static void lua_create_variable_metatable(lua_State *L);
static void lua_create_application_metatable(lua_State *L);
static void lua_create_autoservice_functions(lua_State *L);
+static void lua_create_hangup_function(lua_State *L);
void lua_state_destroy(void *data);
static lua_State *lua_get_state(struct ast_channel *chan);
@@ -479,6 +481,17 @@
}
/*!
+ * \brief Create the hangup check function
+ *
+ * \param L the lua_State to use
+ */
+static void lua_create_hangup_function(lua_State *L)
+{
+ lua_pushcfunction(L, &lua_check_hangup);
+ lua_setglobal(L, "check_hangup");
+}
+
+/*!
* \brief [lua_CFunction] Return a lua 'variable' object (for access from lua, don't call
* directly)
*
@@ -679,6 +692,25 @@
static int lua_autoservice_status(lua_State *L)
{
lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
+ return 1;
+}
+
+/*!
+ * \brief [lua_CFunction] Check if this channel has been hungup or not (for
+ * access from lua, don't call directly)
+ *
+ * \param L the lua_State to use
+ *
+ * \return This function returns true if the channel was hungup
+ */
+static int lua_check_hangup(lua_State *L)
+{
+ struct ast_channel *chan;
+ lua_getfield(L, LUA_REGISTRYINDEX, "channel");
+ chan = lua_touserdata(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushboolean(L, ast_check_hangup(chan));
return 1;
}
@@ -872,6 +904,7 @@
lua_create_application_metatable(L);
lua_create_autoservice_functions(L);
+ lua_create_hangup_function(L);
return 0;
}
More information about the asterisk-commits
mailing list