forked from osmocom/wireshark
Include extcap binaries in the count of things to point out during startup.
The GTK+ version, at least, crashes if there are more "doing XXX..." items put up than the calculated count, so, now that we're putting up items for extcap binaries, we need to count the extcap binaries. Clean up some stuff we found doing this (indentation, a _U_ on something that's used). Change-Id: I1f88042b64ce4b9ae352de37689677c694e3770b Reviewed-on: https://code.wireshark.org/review/19549 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
f7124f64a8
commit
26430ff647
35
extcap.c
35
extcap.c
|
@ -89,6 +89,37 @@ static GHashTable *extcap_prefs_dynamic_vals = NULL;
|
|||
typedef gboolean(*extcap_cb_t)(const gchar *extcap, const gchar *ifname, gchar *output, void *data,
|
||||
gchar **err_str);
|
||||
|
||||
guint extcap_count(void)
|
||||
{
|
||||
const char *dirname = get_extcap_dir();
|
||||
GDir *dir;
|
||||
guint count;
|
||||
|
||||
count = 0;
|
||||
|
||||
if ((dir = g_dir_open(dirname, 0, NULL)) != NULL)
|
||||
{
|
||||
GString *extcap_path = NULL;
|
||||
const gchar *file;
|
||||
|
||||
extcap_path = g_string_new("");
|
||||
while ((file = g_dir_read_name(dir)) != NULL)
|
||||
{
|
||||
/* full path to extcap binary */
|
||||
g_string_printf(extcap_path, "%s" G_DIR_SEPARATOR_S "%s", dirname, file);
|
||||
/* treat anything executable as an extcap binary */
|
||||
if (g_file_test(extcap_path->str, G_FILE_TEST_IS_EXECUTABLE))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
g_dir_close(dir);
|
||||
g_string_free(extcap_path, TRUE);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
extcap_if_exists(const gchar *ifname)
|
||||
{
|
||||
|
@ -175,11 +206,10 @@ extcap_tool_add(const gchar *extcap, const extcap_interface *interface)
|
|||
|
||||
/* Note: args does not need to be NULL-terminated. */
|
||||
static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
|
||||
void *cb_data, char **err_str, const char *ifname _U_)
|
||||
void *cb_data, char **err_str, const char *ifname)
|
||||
{
|
||||
const char *dirname = get_extcap_dir();
|
||||
GDir *dir;
|
||||
const gchar *file;
|
||||
gboolean keep_going;
|
||||
|
||||
keep_going = TRUE;
|
||||
|
@ -187,6 +217,7 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
|
|||
if ((dir = g_dir_open(dirname, 0, NULL)) != NULL)
|
||||
{
|
||||
GString *extcap_path = NULL;
|
||||
const gchar *file;
|
||||
|
||||
extcap_path = g_string_new("");
|
||||
while (keep_going && (file = g_dir_read_name(dir)) != NULL)
|
||||
|
|
4
extcap.h
4
extcap.h
|
@ -63,6 +63,10 @@ struct _extcap_arg;
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Count the number of extcap binaries */
|
||||
guint
|
||||
extcap_count(void);
|
||||
|
||||
/* Registers preferences for all interfaces */
|
||||
void
|
||||
extcap_register_preferences(void);
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#ifdef HAVE_LUA
|
||||
#include <epan/wslua/init_wslua.h>
|
||||
#endif
|
||||
#ifdef HAVE_EXTCAP
|
||||
#include "../../extcap.h"
|
||||
#endif
|
||||
|
||||
#include "../../log.h"
|
||||
#include "../../register.h"
|
||||
|
@ -257,6 +260,9 @@ splash_update(register_action_e action, const char *message, gpointer client_dat
|
|||
preferences, interfaces and configuration */
|
||||
#ifdef HAVE_LUA
|
||||
ul_count += wslua_count_plugins (); /* get count of lua plugins */
|
||||
#endif
|
||||
#ifdef HAVE_EXTCAP
|
||||
ul_count += extcap_count(); /* get count of extcap binaries */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#include "epan/wslua/init_wslua.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EXTCAP
|
||||
#include "../../extcap.h"
|
||||
#endif
|
||||
|
||||
// Uncomment to slow the update progress
|
||||
//#define THROTTLE_STARTUP 1
|
||||
|
||||
|
@ -58,7 +62,10 @@ SplashOverlay::SplashOverlay(QWidget *parent) :
|
|||
// RA_DISSECTORS -> RA_PLUGIN_REGISTER) minus two.
|
||||
int register_add = 5;
|
||||
#ifdef HAVE_LUA
|
||||
register_add += wslua_count_plugins(); /* get count of lua plugins */
|
||||
register_add += wslua_count_plugins(); /* get count of lua plugins */
|
||||
#endif
|
||||
#ifdef HAVE_EXTCAP
|
||||
register_add += extcap_count(); /* get count of extcap binaries */
|
||||
#endif
|
||||
so_ui_->progressBar->setMaximum((int)register_count() + register_add);
|
||||
elapsed_timer_.start();
|
||||
|
|
Loading…
Reference in New Issue