Pull all the "load settings" calls into a epan_load_settings() routine.

That way, nothing using libwireshark needs to know what settings need to
be loaded, they just call epan_load_settings().

Change-Id: I9390e259e286fc4f5acaeaac2767e4c3c4b656af
Reviewed-on: https://code.wireshark.org/review/20983
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-04-09 12:27:57 -07:00
parent 7d5ce06cbe
commit 6b3714254d
13 changed files with 59 additions and 68 deletions

View File

@ -499,6 +499,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
epan_get_user_comment@Base 1.99.2
epan_get_version@Base 1.9.1
epan_init@Base 1.9.1
epan_load_settings@Base 2.3.0
epan_memmem@Base 1.9.1
epan_new@Base 1.12.0~rc1
epan_register_plugin_types@Base 1.12.0~rc1
@ -857,7 +858,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
link_type_vals@Base 2.1.0
list_stat_cmd_args@Base 1.9.1
llc_add_oui@Base 1.9.1
load_decode_as_entries@Base 2.3.0
make_printable_string@Base 1.9.1
manually_resolve_cleanup@Base 1.12.0~rc1
mark_frame_as_depended_upon@Base 1.9.1
@ -1235,11 +1235,8 @@ libwireshark.so.0 libwireshark0 #MINVER#
range_add_value@Base 2.3.0
range_remove_value@Base 2.3.0
ranges_are_equal@Base 1.9.1
read_enabled_and_disabled_lists@Base 2.3.0
read_enabled_protos_list@Base 2.3.0
read_keytab_file@Base 1.9.1
read_keytab_file_from_preferences@Base 1.9.1
read_prefs@Base 1.9.1
read_prefs_file@Base 1.9.1
reassembly_table_register@Base 2.3.0
reassembly_table_destroy@Base 1.9.1

View File

@ -106,7 +106,8 @@ main(int argc, char **argv)
/* set the c-language locale to the native environment. */
setlocale(LC_ALL, "");
read_prefs();
/* Load libwireshark settings from the current profile. */
epan_load_settings();
/* notify all registered modules that have had any of their preferences
changed either from one of the preferences file or from the command

View File

@ -100,8 +100,10 @@ WS_DLL_PUBLIC GList *decode_as_list;
/* Some useful utilities for Decode As */
/** Reset the "decode as" entries and reload ones of the current profile.
* This is called by epan_load_settings(); programs should call that
* rather than individually calling the routines it calls.
*/
WS_DLL_PUBLIC void load_decode_as_entries(void);
extern void load_decode_as_entries(void);
/** Write out the "decode as" entries of the current profile.
*/

View File

@ -52,8 +52,11 @@ proto_enable_heuristic_by_name(const char *name, gboolean enable);
/*
* Read the files that enable and disable protocols and heuristic
* dissectors. Report errors through the UI.
*
* This is called by epan_load_settings(); programs should call that
* rather than individually calling the routines it calls.
*/
WS_DLL_PUBLIC void
extern void
read_enabled_and_disabled_lists(void);
/*

View File

@ -209,6 +209,28 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
return status;
}
/*
* Load all settings, from the current profile, that affect libwireshark.
*/
e_prefs *
epan_load_settings(void)
{
e_prefs *prefs_p;
/* load the decode as entries of the current profile */
load_decode_as_entries();
prefs_p = read_prefs();
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
return prefs_p;
}
void
epan_cleanup(void)
{

View File

@ -28,6 +28,7 @@ extern "C" {
#include <glib.h>
#include <epan/tvbuff.h>
#include <epan/prefs.h>
#include <epan/frame_data.h>
#include "register.h"
#include "ws_symbol_export.h"
@ -102,6 +103,12 @@ gboolean epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer
void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
register_cb cb, void *client_data);
/**
* Load all settings, from the current profile, that affect epan.
*/
WS_DLL_PUBLIC
e_prefs *epan_load_settings(void);
/** cleanup the whole epan module, this is used to be called only once in a program */
WS_DLL_PUBLIC
void epan_cleanup(void);

View File

@ -590,8 +590,11 @@ char *prefs_pref_to_str(pref_t *pref, pref_source_t source);
/* Read the preferences file, fill in "prefs", and return a pointer to it.
If we got an error (other than "it doesn't exist") we report it through
the UI. */
WS_DLL_PUBLIC e_prefs *read_prefs(void);
the UI.
This is called by epan_load_settings(); programs should call that
rather than individually calling the routines it calls. */
extern e_prefs *read_prefs(void);
/* Write out "prefs" to the user's preferences file, and return 0.

View File

@ -541,13 +541,8 @@ main(int argc, char *argv[])
goto clean_exit;
}
prefs_p = read_prefs();
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
#ifdef _WIN32
ws_init_dll_search_path();

View File

@ -201,10 +201,8 @@ main(int argc, char *argv[])
goto clean_exit;
}
/* load the decode as entries of this profile */
load_decode_as_entries();
prefs_p = read_prefs();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
read_filter_list(CFILTER_LIST);
@ -213,12 +211,6 @@ main(int argc, char *argv[])
g_free(err_msg);
}
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
cap_file_init(&cfile);
/* Notify all registered modules that have had any of their preferences

View File

@ -557,7 +557,7 @@ main(int argc, char *argv[])
if (strcmp(argv[2], "column-formats") == 0)
column_dump_column_formats();
else if (strcmp(argv[2], "currentprefs") == 0) {
read_prefs();
epan_load_settings();
write_prefs(NULL);
}
else if (strcmp(argv[2], "decodes") == 0)
@ -597,13 +597,8 @@ main(int argc, char *argv[])
goto clean_exit;
}
prefs_p = read_prefs();
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
cap_file_init(&cfile);

View File

@ -953,7 +953,7 @@ main(int argc, char *argv[])
if (strcmp(argv[2], "column-formats") == 0)
column_dump_column_formats();
else if (strcmp(argv[2], "currentprefs") == 0) {
read_prefs();
epan_load_settings();
write_prefs(NULL);
}
else if (strcmp(argv[2], "decodes") == 0)
@ -1000,21 +1000,13 @@ main(int argc, char *argv[])
goto clean_exit;
}
/* load the decode as entries of this profile */
load_decode_as_entries();
tshark_debug("tshark reading settings");
tshark_debug("tshark reading preferences");
prefs_p = read_prefs();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
read_filter_list(CFILTER_LIST);
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
cap_file_init(&cfile);
/* Print format defaults to this. */

View File

@ -1907,11 +1907,8 @@ read_configuration_files(void)
{
e_prefs *prefs_p;
/* load the decode as entries of this profile */
load_decode_as_entries();
/* Read the preference files. */
prefs_p = read_prefs();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
#ifdef _WIN32
/* if the user wants a console to be always there, well, we should open one for him */
@ -1926,12 +1923,6 @@ read_configuration_files(void)
/* Read the display filter file. */
read_filter_list(DFILTER_LIST);
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
return prefs_p;
}

View File

@ -1107,11 +1107,8 @@ _e_prefs *WiresharkApplication::readConfigurationFiles(bool reset)
proto_reenable_all();
}
/* load the decode as entries of this profile */
load_decode_as_entries();
/* Read the preference files. */
prefs_p = read_prefs();
/* Load libwireshark settings from the current profile. */
prefs_p = epan_load_settings();
#ifdef _WIN32
/* if the user wants a console to be always there, well, we should open one for him */
@ -1126,12 +1123,6 @@ _e_prefs *WiresharkApplication::readConfigurationFiles(bool reset)
/* Read the display filter file. */
read_filter_list(DFILTER_LIST);
/*
* Read the files that enable and disable protocols and heuristic
* dissectors.
*/
read_enabled_and_disabled_lists();
return prefs_p;
}