diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2013-08-13 10:38:30 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2013-08-13 10:38:30 +0000 |
commit | a31a88b142a3deba29ea01b28766cdfcce69269b (patch) | |
tree | 50e57535f6ba1fde1de89e7ca3de4d6825835864 | |
parent | bae2eee028334f658363709fb65b79eff1a8ecb5 (diff) | |
download | wireshark-a31a88b142a3deba29ea01b28766cdfcce69269b.tar.gz wireshark-a31a88b142a3deba29ea01b28766cdfcce69269b.tar.bz2 wireshark-a31a88b142a3deba29ea01b28766cdfcce69269b.zip |
Show the Lua plugin being loaded in the splash screen.
svn path=/trunk/; revision=51335
-rw-r--r-- | epan/wslua/Makefile.am | 1 | ||||
-rw-r--r-- | epan/wslua/init_wslua.c | 62 | ||||
-rw-r--r-- | epan/wslua/init_wslua.h | 30 | ||||
-rw-r--r-- | ui/gtk/about_dlg.c | 5 |
4 files changed, 80 insertions, 18 deletions
diff --git a/epan/wslua/Makefile.am b/epan/wslua/Makefile.am index f4a3b4e587..a037e2f964 100644 --- a/epan/wslua/Makefile.am +++ b/epan/wslua/Makefile.am @@ -46,6 +46,7 @@ libwslua_la_SOURCES = \ taps_wslua.c \ register_wslua.c \ init_wslua.c \ + init_wslua.h \ wslua.h libwslua_la_LIBADD = @LUA_LIBS@ diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 577dab9fe5..5e16c53bde 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -29,6 +29,7 @@ #include "config.h" #include "wslua.h" +#include "init_wslua.h" #include <epan/dissectors/packet-frame.h> #include <math.h> #include <epan/expert.h> @@ -273,12 +274,12 @@ static int wslua_panic(lua_State* LS) { return 0; /* keep gcc happy */ } -static void lua_load_plugins (const char *dirname) -{ +static int lua_load_plugins(const char *dirname, register_cb cb, gpointer client_data, gboolean count_only) { WS_DIR *dir; /* scanned directory */ WS_DIRENT *file; /* current file */ gchar *filename, *dot; const gchar *name; + int plugins_counter = 0; if ((dir = ws_dir_open(dirname, 0, NULL)) != NULL) { while ((file = ws_dir_read_name(dir)) != NULL) { @@ -289,7 +290,7 @@ static void lua_load_plugins (const char *dirname) filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, name); if (test_for_directory(filename) == EISDIR) { - lua_load_plugins(filename); + plugins_counter += lua_load_plugins(filename, cb, client_data, count_only); g_free(filename); continue; } @@ -308,14 +309,46 @@ static void lua_load_plugins (const char *dirname) } if (file_exists(filename)) { - if (lua_load_script(filename)) { - wslua_add_plugin(g_strdup(name), g_strdup(""), g_strdup(filename)); + if (!count_only) { + if (cb) + (*cb)(RA_LUA_PLUGINS, name, client_data); + if (lua_load_script(filename)) { + wslua_add_plugin(g_strdup(name), g_strdup(""), g_strdup(filename)); + } } + plugins_counter++; } g_free(filename); } ws_dir_close(dir); } + + return plugins_counter; +} + +int wslua_count_plugins(void) { + gchar* filename; + int plugins_counter; + + /* count global scripts */ + plugins_counter = lua_load_plugins(get_plugin_dir(), NULL, NULL, TRUE); + + /* count users init.lua */ + filename = get_persconffile_path("init.lua", FALSE); + if ((file_exists(filename))) { + plugins_counter++; + } + g_free(filename); + + /* count user scripts */ + filename = get_plugins_pers_dir(); + plugins_counter += lua_load_plugins(filename, NULL, NULL, TRUE); + g_free(filename); + + /* count scripts from command line */ + plugins_counter += ex_opt_count("lua_script"); + + return plugins_counter; } int wslua_init(register_cb cb, gpointer client_data) { @@ -323,13 +356,6 @@ int wslua_init(register_cb cb, gpointer client_data) { 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, (GLogLevelFlags)(G_LOG_LEVEL_CRITICAL| G_LOG_LEVEL_WARNING| @@ -383,7 +409,7 @@ int wslua_init(register_cb cb, gpointer client_data) { } /* load global scripts */ - lua_load_plugins(get_plugin_dir()); + lua_load_plugins(get_plugin_dir(), cb, client_data, FALSE); /* check whether we should run other scripts even if running superuser */ lua_getglobal(L,"run_user_scripts_when_superuser"); @@ -392,24 +418,26 @@ int wslua_init(register_cb cb, gpointer client_data) { run_anyway = TRUE; } - /* if we are indeed superuser run user scripts only if told to do so */ if ( (!started_with_special_privs()) || run_anyway ) { + /* load users init.lua */ filename = get_persconffile_path("init.lua", FALSE); - if ((file_exists(filename))) { + if (cb) + (*cb)(RA_LUA_PLUGINS, get_basename(filename), client_data); lua_load_script(filename); } - g_free(filename); /* load user scripts */ filename = get_plugins_pers_dir(); - lua_load_plugins(filename); + lua_load_plugins(filename, cb, client_data, FALSE); g_free(filename); /* load scripts from command line */ while((filename = (gchar *)ex_opt_get_next("lua_script"))) { + if (cb) + (*cb)(RA_LUA_PLUGINS, get_basename(filename), client_data); lua_load_script(filename); } } diff --git a/epan/wslua/init_wslua.h b/epan/wslua/init_wslua.h new file mode 100644 index 0000000000..9072e6b9b1 --- /dev/null +++ b/epan/wslua/init_wslua.h @@ -0,0 +1,30 @@ +/* + * init_wslua.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __INIT_WSLUA_H__ +#define __INIT_WSLUA_H__ + +WS_DLL_PUBLIC int wslua_count_plugins(void); + +#endif /* __INIT_WSLUA_H__ */ diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c index d22837946d..906c0717d0 100644 --- a/ui/gtk/about_dlg.c +++ b/ui/gtk/about_dlg.c @@ -37,6 +37,9 @@ #ifdef HAVE_GEOIP #include <epan/geoip_db.h> #endif +#ifdef HAVE_LUA +#include <epan/wslua/init_wslua.h> +#endif #include "../log.h" #include "../version_info.h" @@ -248,7 +251,7 @@ splash_update(register_action_e action, const char *message, gpointer client_dat registering plugins, handingoff plugins, preferences and configuration */ #ifdef HAVE_LUA - ul_count++; /* additional one for lua plugins */ + ul_count += wslua_count_plugins (); /* get count of lua plugins */ #endif #ifdef HAVE_PYTHON ul_count += 2; /* additional 2 for python register and handoff */ |