From 3e75b436a0088ba55225bc65e39ce2bda2bcfa78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Sun, 2 Oct 2011 13:39:35 +0000 Subject: Added register action for loading Lua plugins. Removed an unused argument to wslua_init(). svn path=/trunk/; revision=39214 --- epan/epan.c | 2 +- epan/wslua/init_wslua.c | 14 +++++++++----- epan/wslua/wslua.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'epan') diff --git a/epan/epan.c b/epan/epan.c index 4aebc057e2..c5cf3b3fe9 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -111,7 +111,7 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da host_name_lookup_init(); expert_init(); #ifdef HAVE_LUA_5_1 - wslua_init(NULL); + wslua_init(cb, client_data); #endif #ifdef HAVE_GEOIP geoip_db_init(); diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 37410a0829..ede501fd38 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -317,11 +317,18 @@ static void lua_load_plugins (const char *dirname) } } -int wslua_init(lua_State* LS) { +int wslua_init(register_cb cb, gpointer client_data) { gchar* filename; const funnel_ops_t* ops = funnel_get_funnel_ops(); gboolean run_anyway = FALSE; + /* + ** TBD: count the number of lua scripts to load in splash_update() + ** and call cb for each file instead of once for all files. + */ + if(cb) + (*cb)(RA_LUA_PLUGINS, NULL, client_data); + /* set up the logger */ g_log_set_handler(LOG_DOMAIN_LUA, G_LOG_LEVEL_CRITICAL| G_LOG_LEVEL_WARNING| @@ -331,10 +338,7 @@ int wslua_init(lua_State* LS) { ops ? ops->logger : basic_logger, NULL); if (!L) { - if (LS) - L = LS; - else - L = luaL_newstate(); + L = luaL_newstate(); } WSLUA_INIT(L); diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h index a5d38d6658..a7a6447354 100644 --- a/epan/wslua/wslua.h +++ b/epan/wslua/wslua.h @@ -403,7 +403,7 @@ extern void clear_outstanding_TreeItem(void); extern void wslua_print_stack(char* s, lua_State* L); -extern int wslua_init(lua_State* L); +extern int wslua_init(register_cb cb, gpointer client_data); extern tap_extractor_t wslua_get_tap_extractor(const gchar* name); extern int wslua_set_tap_enums(lua_State* L); -- cgit v1.2.3