From ce3d56920b15facbb64b3caf0d823a3f57c0dded Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Fri, 22 Dec 2017 09:14:07 -0500 Subject: Remove as much trailing whitespace as possible. Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0 --- pbx/pbx_lua.c | 99 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 50 deletions(-) (limited to 'pbx/pbx_lua.c') diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c index 77762e226..655d2df2e 100644 --- a/pbx/pbx_lua.c +++ b/pbx/pbx_lua.c @@ -16,7 +16,7 @@ * at the top of the source tree. */ -/*! +/*! * \file * * \author Matthew Nicholson @@ -157,7 +157,7 @@ static void lua_datastore_fixup(void *data, struct ast_channel *old_chan, struct static int lua_pbx_findapp(lua_State *L) { const char *app_name = luaL_checkstring(L, 2); - + lua_newtable(L); lua_pushstring(L, "name"); @@ -198,7 +198,7 @@ static int lua_pbx_exec(lua_State *L) lua_getfield(L, 1, "name"); app_name = ast_strdupa(lua_tostring(L, -1)); lua_pop(L, 1); - + if (!(app = pbx_findapp(app_name))) { lua_pushstring(L, "application '"); lua_pushstring(L, app_name); @@ -206,16 +206,16 @@ static int lua_pbx_exec(lua_State *L) lua_concat(L, 3); return lua_error(L); } - + lua_getfield(L, LUA_REGISTRYINDEX, "channel"); chan = lua_touserdata(L, -1); lua_pop(L, 1); - + context = ast_strdupa(ast_channel_context(chan)); exten = ast_strdupa(ast_channel_exten(chan)); priority = ast_channel_priority(chan); - + lua_concat_args(L, 2, nargs); data = lua_tostring(L, -1); @@ -268,20 +268,20 @@ static int lua_pbx_exec(lua_State *L) /* goto detected - construct error message */ lua_insert(L, -3); - - lua_pushliteral(L, " changed from "); - lua_insert(L, -3); - - lua_pushliteral(L, " to "); - lua_insert(L, -2); - - lua_concat(L, 5); - - ast_debug(2, "Goto detected: %s\n", lua_tostring(L, -1)); - lua_pop(L, 1); - - /* let the lua engine know it needs to return control to the pbx */ - lua_pushinteger(L, LUA_GOTO_DETECTED); + + lua_pushliteral(L, " changed from "); + lua_insert(L, -3); + + lua_pushliteral(L, " to "); + lua_insert(L, -2); + + lua_concat(L, 5); + + ast_debug(2, "Goto detected: %s\n", lua_tostring(L, -1)); + lua_pop(L, 1); + + /* let the lua engine know it needs to return control to the pbx */ + lua_pushinteger(L, LUA_GOTO_DETECTED); lua_error(L); return 0; @@ -312,7 +312,7 @@ static int lua_get_variable_value(lua_State *L) lua_pushstring(L, "User probably used '.' instead of ':' for retrieving a channel variable value"); return lua_error(L); } - + lua_getfield(L, LUA_REGISTRYINDEX, "channel"); chan = lua_touserdata(L, -1); lua_pop(L, 1); @@ -320,14 +320,14 @@ static int lua_get_variable_value(lua_State *L) lua_getfield(L, 1, "name"); name = ast_strdupa(lua_tostring(L, -1)); lua_pop(L, 1); - + lua_getfield(L, LUA_REGISTRYINDEX, "autoservice"); autoservice = lua_toboolean(L, -1); lua_pop(L, 1); if (autoservice) ast_autoservice_stop(chan); - + /* if this is a dialplan function then use ast_func_read(), otherwise * use pbx_retrieve_variable() */ if (!ast_strlen_zero(name) && name[strlen(name) - 1] == ')') { @@ -335,7 +335,7 @@ static int lua_get_variable_value(lua_State *L) } else { pbx_retrieve_variable(chan, name, &value, workspace, LUA_BUF_SIZE, ast_channel_varshead(chan)); } - + if (autoservice) ast_autoservice_start(chan); @@ -351,7 +351,7 @@ static int lua_get_variable_value(lua_State *L) /*! * \brief [lua_CFunction] Used to set the value of a variable or dialplan * function (for access from lua, don't call directly) - * + * * This function is the 'set()' function in the following example as would be * seen in extensions.lua. * @@ -375,7 +375,7 @@ static int lua_set_variable_value(lua_State *L) lua_pop(L, 1); value = luaL_checkstring(L, 2); - + lua_getfield(L, LUA_REGISTRYINDEX, "channel"); chan = lua_touserdata(L, -1); lua_pop(L, 1); @@ -388,7 +388,7 @@ static int lua_set_variable_value(lua_State *L) ast_autoservice_stop(chan); pbx_builtin_setvar_helper(chan, name, value); - + if (autoservice) ast_autoservice_start(chan); @@ -431,10 +431,10 @@ static void lua_push_variable_table(lua_State *L) lua_insert(L, -2); /* move the table after the name */ lua_setfield(L, -2, "name"); - + lua_pushcfunction(L, &lua_get_variable_value); lua_setfield(L, -2, "get"); - + lua_pushcfunction(L, &lua_set_variable_value); lua_setfield(L, -2, "set"); } @@ -497,7 +497,7 @@ static void lua_create_variable_metatable(lua_State *L) /*! * \brief Create the 'application' metatable, used to execute asterisk - * applications from lua + * applications from lua * * \param L the lua_State to use */ @@ -521,7 +521,7 @@ static void lua_create_autoservice_functions(lua_State *L) { lua_pushcfunction(L, &lua_autoservice_start); lua_setglobal(L, "autoservice_start"); - + lua_pushcfunction(L, &lua_autoservice_stop); lua_setglobal(L, "autoservice_stop"); @@ -546,7 +546,7 @@ static void lua_create_hangup_function(lua_State *L) /*! * \brief [lua_CFunction] Return a lua 'variable' object (for access from lua, don't call * directly) - * + * * This function is called to lookup a variable construct a 'variable' object. * It would be called in the following example as would be seen in * extensions.lua. @@ -562,14 +562,14 @@ static int lua_get_variable(lua_State *L) char *value = NULL; char *workspace = ast_alloca(LUA_BUF_SIZE); workspace[0] = '\0'; - + lua_getfield(L, LUA_REGISTRYINDEX, "channel"); chan = lua_touserdata(L, -1); lua_pop(L, 1); lua_pushvalue(L, 2); lua_push_variable_table(L); - + /* if this is not a request for a dialplan funciton attempt to retrieve * the value of the variable */ if (!ast_strlen_zero(name) && name[strlen(name) - 1] != ')') { @@ -581,13 +581,13 @@ static int lua_get_variable(lua_State *L) lua_setfield(L, -2, "value"); } - return 1; + return 1; } /*! * \brief [lua_CFunction] Set the value of a channel variable or dialplan * function (for access from lua, don't call directly) - * + * * This function is called to set a variable or dialplan function. It would be * called in the following example as would be seen in extensions.lua. * @@ -614,7 +614,7 @@ static int lua_set_variable(lua_State *L) ast_autoservice_stop(chan); pbx_builtin_setvar_helper(chan, name, value); - + if (autoservice) ast_autoservice_start(chan); @@ -656,7 +656,7 @@ static void lua_concat_args(lua_State *L, int start, int nargs) { /*! * \brief [lua_CFunction] Create a 'variable' object for accessing a dialplan * function (for access from lua, don't call directly) - * + * * This function is called to create a 'variable' object to access a dialplan * function. It would be called in the following example as would be seen in * extensions.lua. @@ -825,7 +825,7 @@ static int lua_error_function(lua_State *L) /*! * \brief Store the sort order of each context - + * In the event of an error, an error string will be pushed onto the lua stack. * * \retval 0 success @@ -902,7 +902,7 @@ static int lua_sort_extensions(lua_State *L) return 1; } } - + /* remove the extensions table and the extensions_order table */ lua_pop(L, 2); return 0; @@ -960,7 +960,7 @@ static int lua_register_switches(lua_State *L) return 1; } } - + /* remove the extensions table */ lua_pop(L, 1); return 0; @@ -1156,11 +1156,11 @@ static char *lua_read_extensions_file(lua_State *L, long *size) */ static int lua_load_extensions(lua_State *L, struct ast_channel *chan) { - + /* store a pointer to this channel */ lua_pushlightuserdata(L, chan); lua_setfield(L, LUA_REGISTRYINDEX, "channel"); - + luaL_openlibs(L); /* load and sort extensions */ @@ -1215,10 +1215,10 @@ static int lua_reload_extensions(lua_State *L) config_file_data = data; config_file_size = size; - + /* merge our new contexts */ ast_merge_contexts_and_delete(&local_contexts, local_table, registrar); - /* merge_contexts_and_delete will actually, at the correct moment, + /* merge_contexts_and_delete will actually, at the correct moment, set the global dialplan pointers to your local_contexts and local_table. It then will free up the old tables itself. Just be sure not to hang onto the pointers. */ @@ -1376,7 +1376,7 @@ static int matchmore(struct ast_channel *chan, const char *context, const char * ast_module_user_remove(u); return 0; } - + res = lua_find_extension(L, context, exten, priority, &matchmore, 0); if (!chan) lua_close(L); @@ -1394,7 +1394,7 @@ static int exec(struct ast_channel *chan, const char *context, const char *exten ast_log(LOG_ERROR, "Error adjusting use count, probably could not allocate memory\n"); return -1; } - + L = lua_get_state(chan); if (!L) { ast_module_user_remove(u); @@ -1420,10 +1420,10 @@ static int exec(struct ast_channel *chan, const char *context, const char *exten lua_pop(L, 1); lua_update_registry(L, context, exten, priority); - + lua_pushstring(L, context); lua_pushstring(L, exten); - + res = lua_pcall(L, 2, 0, error_func); if (res) { if (res == LUA_ERRRUN) { @@ -1678,4 +1678,3 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Lua PBX Switch", .unload = unload_module, .reload = reload, ); - -- cgit v1.2.3