forked from osmocom/wireshark
wsutil: Add configuration namespaces.
Rename init_progfile_dir to configuration_init. Add an argument which specifies our configuration namespace, which can be "Wireshark" (default) or "Logwolf".pespin/osmux-wip
parent
6d2ab6900f
commit
3086774fa6
|
@ -1667,6 +1667,12 @@ if(ENABLE_APPLICATION_BUNDLE)
|
|||
# Xcode
|
||||
set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
|
||||
endif()
|
||||
if(CMAKE_CFG_INTDIR STREQUAL ".")
|
||||
set(_logshark_plugin_dir "${CMAKE_BINARY_DIR}/run/Logshark.app/Contents/PlugIns/logwolf/${PLUGIN_PATH_ID}")
|
||||
else()
|
||||
# Xcode
|
||||
set(_logshark_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Logshark.app/Contents/PlugIns/logwolf/${PLUGIN_PATH_ID}")
|
||||
endif()
|
||||
elseif(WIN32 AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
|
||||
set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
|
||||
else()
|
||||
|
|
10
capinfos.c
10
capinfos.c
|
@ -1569,7 +1569,7 @@ capinfos_cmdarg_err_cont(const char *msg_format, va_list ap)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines capinfos_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -1630,12 +1630,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"capinfos: Can't get pathname of directory containing the capinfos program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("capinfos", &capinfos_report_routines);
|
||||
|
|
10
captype.c
10
captype.c
|
@ -78,7 +78,7 @@ captype_cmdarg_err_cont(const char *msg_format, va_list ap)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines captype_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -137,12 +137,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"captype: Can't get pathname of directory containing the captype program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("captype", &captype_report_routines);
|
||||
|
|
10
dftest.c
10
dftest.c
|
@ -43,7 +43,7 @@ static void dftest_cmdarg_err_cont(const char *fmt, va_list ap);
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines dftest_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -77,11 +77,11 @@ main(int argc, char **argv)
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr, "dftest: Can't get pathname of directory containing the dftest program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("dftest", &dftest_report_routines);
|
||||
|
|
10
editcap.c
10
editcap.c
|
@ -1102,7 +1102,7 @@ process_new_idbs(wtap *wth, wtap_dumper *pdh, GArray *idbs_seen,
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines editcap_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -1203,12 +1203,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"editcap: Can't get pathname of directory containing the editcap program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("editcap", &editcap_report_routines);
|
||||
|
|
|
@ -2539,7 +2539,7 @@ int main(int argc, char *argv[]) {
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -546,7 +546,7 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -486,7 +486,7 @@ close_out:
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char* init_progfile_dir_error;
|
||||
char* configuration_init_error;
|
||||
int option_idx = 0;
|
||||
int result;
|
||||
unsigned int interface_id = 0;
|
||||
|
@ -506,11 +506,11 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
extcap_base_set_util_info(extcap_conf, argv[0], DPAUXMON_VERSION_MAJOR, DPAUXMON_VERSION_MINOR, DPAUXMON_VERSION_RELEASE,
|
||||
|
|
|
@ -135,7 +135,7 @@ int main(int argc, char* argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -331,7 +331,7 @@ static int list_config(char *interface)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char* init_progfile_dir_error;
|
||||
char* configuration_init_error;
|
||||
int result;
|
||||
int option_idx = 0;
|
||||
int start_from_entries = 10;
|
||||
|
@ -353,11 +353,11 @@ int main(int argc, char **argv)
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
help_url = data_file_url("sdjournal.html");
|
||||
|
|
|
@ -376,7 +376,7 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -369,7 +369,7 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -539,7 +539,7 @@ int main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
ws_warning("Can't get pathname of directory containing the extcap program: %s.",
|
||||
err_msg);
|
||||
|
|
|
@ -151,7 +151,7 @@ fuzz_prefs_apply(void)
|
|||
static int
|
||||
fuzz_init(int argc _U_, char **argv)
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
|
||||
static const struct report_message_routines fuzzshark_report_routines = {
|
||||
failure_message,
|
||||
|
@ -256,10 +256,10 @@ fuzz_init(int argc _U_, char **argv)
|
|||
/*
|
||||
* Attempt to get the pathname of the executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
fprintf(stderr, "fuzzshark: Can't get pathname of oss-fuzzshark program: %s.\n", init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr, "fuzzshark: Can't get pathname of oss-fuzzshark program: %s.\n", configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
/* Initialize the version information. */
|
||||
|
|
10
mergecap.c
10
mergecap.c
|
@ -184,7 +184,7 @@ merge_callback(merge_event event, int num,
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines mergecap_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -241,12 +241,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"mergecap: Can't get pathname of directory containing the mergecap program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("mergecap", &mergecap_report_routines);
|
||||
|
|
|
@ -21,6 +21,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
codecs_init@Base 3.1.0
|
||||
codecs_register_plugin@Base 3.1.0
|
||||
config_file_exists_with_entries@Base 2.9.0
|
||||
configuration_init@Base 3.7.0
|
||||
copy_file_binary_mode@Base 1.12.0~rc1
|
||||
copy_persconffile_profile@Base 1.12.0~rc1
|
||||
crc11_307_noreflect_noxor@Base 1.10.0
|
||||
|
@ -115,7 +116,6 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
ieee80211_mhz_to_chan@Base 1.99.7
|
||||
ieee80211_mhz_to_str@Base 1.99.7
|
||||
init_process_policies@Base 1.10.0
|
||||
init_progfile_dir@Base 1.12.0~rc1
|
||||
init_report_message@Base 2.3.0
|
||||
int64_to_str_back@Base 3.5.1
|
||||
int_to_str_back@Base 3.5.1
|
||||
|
|
12
randpkt.c
12
randpkt.c
|
@ -99,7 +99,7 @@ usage(gboolean is_error)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines randpkt_report_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -144,12 +144,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"capinfos: Can't get pathname of directory containing the capinfos program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
"capinfos: Can't get pathname of directory containing the capinfos program: %s.\n",
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("randpkt", &randpkt_report_routines);
|
||||
|
|
|
@ -479,7 +479,7 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
fprintf(stderr, "rawshark: Can't get pathname of rawshark program: %s.\n",
|
||||
err_msg);
|
||||
|
|
10
reordercap.c
10
reordercap.c
|
@ -159,7 +159,7 @@ reordercap_cmdarg_err_cont(const char *msg_format, va_list ap)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
static const struct report_message_routines reordercap_message_routines = {
|
||||
failure_message,
|
||||
failure_message,
|
||||
|
@ -218,12 +218,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"reordercap: Can't get pathname of directory containing the reordercap program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
init_report_message("reordercap", &reordercap_message_routines);
|
||||
|
|
8
sharkd.c
8
sharkd.c
|
@ -98,7 +98,7 @@ print_current_user(void)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
|
||||
char *err_msg = NULL;
|
||||
e_prefs *prefs_p;
|
||||
|
@ -136,10 +136,10 @@ main(int argc, char *argv[])
|
|||
/*
|
||||
* Attempt to get the pathname of the executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr, "sharkd: Can't get pathname of sharkd program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
}
|
||||
|
||||
/* Initialize the version information. */
|
||||
|
|
10
tfshark.c
10
tfshark.c
|
@ -267,7 +267,7 @@ print_current_user(void)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *init_progfile_dir_error;
|
||||
char *configuration_init_error;
|
||||
int opt;
|
||||
static const struct ws_option long_options[] = {
|
||||
{"help", ws_no_argument, NULL, 'h'},
|
||||
|
@ -359,12 +359,12 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
init_progfile_dir_error = init_progfile_dir(argv[0]);
|
||||
if (init_progfile_dir_error != NULL) {
|
||||
configuration_init_error = configuration_init(argv[0], NULL);
|
||||
if (configuration_init_error != NULL) {
|
||||
fprintf(stderr,
|
||||
"tfshark: Can't get pathname of directory containing the tfshark program: %s.\n",
|
||||
init_progfile_dir_error);
|
||||
g_free(init_progfile_dir_error);
|
||||
configuration_init_error);
|
||||
g_free(configuration_init_error);
|
||||
}
|
||||
|
||||
initialize_funnel_ops();
|
||||
|
|
2
tshark.c
2
tshark.c
|
@ -845,7 +845,7 @@ main(int argc, char *argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
err_msg = init_progfile_dir(argv[0]);
|
||||
err_msg = configuration_init(argv[0], NULL);
|
||||
if (err_msg != NULL) {
|
||||
fprintf(stderr,
|
||||
"tshark: Can't get pathname of directory containing the tshark program: %s.\n"
|
||||
|
|
|
@ -560,7 +560,7 @@ int main(int argc, char *qt_argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
/* init_progfile_dir_error = */ init_progfile_dir(argv[0]);
|
||||
/* configuration_init_error = */ configuration_init(argv[0], NULL);
|
||||
/* ws_log(NULL, LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir()); */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -560,7 +560,7 @@ int main(int argc, char *qt_argv[])
|
|||
* Attempt to get the pathname of the directory containing the
|
||||
* executable file.
|
||||
*/
|
||||
/* init_progfile_dir_error = */ init_progfile_dir(argv[0]);
|
||||
/* configuration_init_error = */ configuration_init(argv[0], "Logwolf");
|
||||
/* ws_log(NULL, LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir()); */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -613,7 +613,7 @@ int main(int argc, char *qt_argv[])
|
|||
#endif /* _WIN32 */
|
||||
|
||||
/* Get the compile-time version information string */
|
||||
ws_init_version_info("Logshark", gather_wireshark_qt_compiled_info,
|
||||
ws_init_version_info("Logwolf", gather_wireshark_qt_compiled_info,
|
||||
gather_wireshark_runtime_info);
|
||||
|
||||
/* Create the user profiles directory */
|
||||
|
|
|
@ -456,7 +456,7 @@ init_dll_load_paths()
|
|||
if (program_path && system_path && npcap_path)
|
||||
return TRUE;
|
||||
|
||||
/* XXX - Duplicate code in filesystem.c:init_progfile_dir */
|
||||
/* XXX - Duplicate code in filesystem.c:configuration_init */
|
||||
if (GetModuleFileName(NULL, path_w, MAX_PATH) == 0 || GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "config.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#define WS_LOG_DOMAIN LOG_DOMAIN_WSUTIL
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -49,7 +51,19 @@
|
|||
#define PLUGINS_DIR_NAME "plugins"
|
||||
#define PROFILES_INFO_NAME "profile_files.txt"
|
||||
|
||||
#define ENV_CONFIG_PATH_VAR "WIRESHARK_CONFIG_DIR"
|
||||
/*
|
||||
* Application configuration namespace. Used to construct configuration
|
||||
* paths and environment variables.
|
||||
*/
|
||||
enum configuration_namespace_e {
|
||||
CONFIGURATION_NAMESPACE_UNINITIALIZED,
|
||||
CONFIGURATION_NAMESPACE_WIRESHARK,
|
||||
CONFIGURATION_NAMESPACE_LOGWOLF
|
||||
};
|
||||
enum configuration_namespace_e configuration_namespace = CONFIGURATION_NAMESPACE_UNINITIALIZED;
|
||||
|
||||
#define CONFIGURATION_NAMESPACE_LOWER (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "wireshark" : "logwolf")
|
||||
#define CONFIGURATION_ENVIRONMENT_VARIABLE(suffix) (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "WIRESHARK_" suffix : "LOGWOLF_" suffix)
|
||||
|
||||
char *persconffile_dir = NULL;
|
||||
char *datafile_dir = NULL;
|
||||
|
@ -258,6 +272,35 @@ static char *appbundle_dir;
|
|||
*/
|
||||
static gboolean running_in_build_directory_flag = FALSE;
|
||||
|
||||
/*
|
||||
* Set our configuration namespace. This will be used for top-level
|
||||
* configuration directory names and environment variable prefixes.
|
||||
*/
|
||||
static void
|
||||
set_configuration_namespace(const char *namespace_name)
|
||||
{
|
||||
|
||||
if (namespace_name != CONFIGURATION_NAMESPACE_UNINITIALIZED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!namespace_name || g_ascii_strcasecmp(namespace_name, "wireshark") == 0)
|
||||
{
|
||||
configuration_namespace = CONFIGURATION_NAMESPACE_WIRESHARK;
|
||||
}
|
||||
else if (namespace_name && g_ascii_strcasecmp(namespace_name, "logwolf") == 0)
|
||||
{
|
||||
configuration_namespace = CONFIGURATION_NAMESPACE_LOGWOLF;
|
||||
}
|
||||
else
|
||||
{
|
||||
ws_error("Unknown configuration namespace %s", namespace_name);
|
||||
}
|
||||
|
||||
ws_debug("Using configuration namespace %s.",
|
||||
configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "Wireshark" : "Logwolf");
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/*
|
||||
* Get the pathname of the executable using various platform-
|
||||
|
@ -467,14 +510,17 @@ get_executable_path(void)
|
|||
* g_mallocated string containing an error on failure.
|
||||
*/
|
||||
char *
|
||||
init_progfile_dir(
|
||||
configuration_init(
|
||||
#ifdef _WIN32
|
||||
const char* arg0 _U_
|
||||
const char* arg0 _U_,
|
||||
#else
|
||||
const char* arg0
|
||||
const char* arg0,
|
||||
#endif
|
||||
const char *namespace_name
|
||||
)
|
||||
{
|
||||
set_configuration_namespace(namespace_name);
|
||||
|
||||
#ifdef _WIN32
|
||||
TCHAR prog_pathname_w[_MAX_PATH+2];
|
||||
char *prog_pathname;
|
||||
|
@ -547,7 +593,7 @@ init_progfile_dir(
|
|||
char *dir_end;
|
||||
|
||||
/*
|
||||
* Check whether WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set in the
|
||||
* Check whether XXX_RUN_FROM_BUILD_DIRECTORY is set in the
|
||||
* environment; if so, set running_in_build_directory_flag if we
|
||||
* weren't started with special privileges. (If we were started
|
||||
* with special privileges, it's not safe to allow the user to point
|
||||
|
@ -555,9 +601,11 @@ init_progfile_dir(
|
|||
* set, causes us to look for plugins and the like in the build
|
||||
* directory.)
|
||||
*/
|
||||
if (g_getenv("WIRESHARK_RUN_FROM_BUILD_DIRECTORY") != NULL
|
||||
&& !started_with_special_privs())
|
||||
const char *run_from_envar = CONFIGURATION_ENVIRONMENT_VARIABLE("RUN_FROM_BUILD_DIRECTORY");
|
||||
if (g_getenv(run_from_envar) != NULL
|
||||
&& !started_with_special_privs()) {
|
||||
running_in_build_directory_flag = TRUE;
|
||||
}
|
||||
|
||||
execname = get_executable_path();
|
||||
if (execname == NULL) {
|
||||
|
@ -841,13 +889,14 @@ get_datafile_dir(void)
|
|||
}
|
||||
#else
|
||||
|
||||
if (g_getenv("WIRESHARK_DATA_DIR") && !started_with_special_privs()) {
|
||||
const char *data_dir_envar = CONFIGURATION_ENVIRONMENT_VARIABLE("DATA_DIR");
|
||||
if (g_getenv(data_dir_envar) && !started_with_special_privs()) {
|
||||
/*
|
||||
* The user specified a different directory for data files
|
||||
* and we aren't running with special privileges.
|
||||
* XXX - We might be able to dispense with the priv check
|
||||
*/
|
||||
datafile_dir = g_strdup(g_getenv("WIRESHARK_DATA_DIR"));
|
||||
datafile_dir = g_strdup(g_getenv(data_dir_envar));
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
|
@ -860,8 +909,8 @@ get_datafile_dir(void)
|
|||
* it; we don't need to call started_with_special_privs().)
|
||||
*/
|
||||
else if (appbundle_dir != NULL) {
|
||||
datafile_dir = ws_strdup_printf("%s/Contents/Resources/share/wireshark",
|
||||
appbundle_dir);
|
||||
datafile_dir = ws_strdup_printf("%s/Contents/Resources/share/%s",
|
||||
appbundle_dir, CONFIGURATION_NAMESPACE_LOWER);
|
||||
}
|
||||
#endif
|
||||
else if (running_in_build_directory_flag && progfile_dir != NULL) {
|
||||
|
@ -881,7 +930,6 @@ get_datafile_dir(void)
|
|||
} else {
|
||||
datafile_dir = g_strdup(DATA_DIR);
|
||||
}
|
||||
|
||||
#endif
|
||||
return datafile_dir;
|
||||
}
|
||||
|
@ -959,12 +1007,13 @@ init_plugin_dir(void)
|
|||
*/
|
||||
plugin_dir = g_build_filename(get_progfile_dir(), "plugins", (gchar *)NULL);
|
||||
} else {
|
||||
if (g_getenv("WIRESHARK_PLUGIN_DIR") && !started_with_special_privs()) {
|
||||
const char *plugin_dir_envar = CONFIGURATION_ENVIRONMENT_VARIABLE("PLUGIN_DIR");
|
||||
if (g_getenv(plugin_dir_envar) && !started_with_special_privs()) {
|
||||
/*
|
||||
* The user specified a different directory for plugins
|
||||
* and we aren't running with special privileges.
|
||||
*/
|
||||
plugin_dir = g_strdup(g_getenv("WIRESHARK_PLUGIN_DIR"));
|
||||
plugin_dir = g_strdup(g_getenv(plugin_dir_envar));
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
|
@ -977,7 +1026,8 @@ init_plugin_dir(void)
|
|||
* it; we don't need to call started_with_special_privs().)
|
||||
*/
|
||||
else if (appbundle_dir != NULL) {
|
||||
plugin_dir = g_build_filename(appbundle_dir, "Contents/PlugIns/wireshark", (gchar *)NULL);
|
||||
plugin_dir = g_build_filename(appbundle_dir, "Contents/PlugIns",
|
||||
CONFIGURATION_NAMESPACE_LOWER, (gchar *)NULL);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
|
@ -995,7 +1045,8 @@ init_plugin_pers_dir(void)
|
|||
#ifdef _WIN32
|
||||
plugin_pers_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
|
||||
#else
|
||||
plugin_pers_dir = g_build_filename(g_get_home_dir(), ".local/lib/wireshark/" PLUGINS_DIR_NAME, (gchar *)NULL);
|
||||
plugin_pers_dir = g_build_filename(g_get_home_dir(), ".local/lib",
|
||||
CONFIGURATION_NAMESPACE_LOWER, PLUGINS_DIR_NAME, (gchar *)NULL);
|
||||
#endif
|
||||
#endif /* defined(HAVE_PLUGINS) || defined(HAVE_LUA) */
|
||||
}
|
||||
|
@ -1061,12 +1112,13 @@ get_plugins_pers_dir_with_version(void)
|
|||
static char *extcap_dir = NULL;
|
||||
|
||||
static void init_extcap_dir(void) {
|
||||
if (g_getenv("WIRESHARK_EXTCAP_DIR") && !started_with_special_privs()) {
|
||||
const char *extcap_dir_envar = CONFIGURATION_ENVIRONMENT_VARIABLE("EXTCAP_DIR");
|
||||
if (g_getenv(extcap_dir_envar) && !started_with_special_privs()) {
|
||||
/*
|
||||
* The user specified a different directory for extcap hooks
|
||||
* and we aren't running with special privileges.
|
||||
*/
|
||||
extcap_dir = g_strdup(g_getenv("WIRESHARK_EXTCAP_DIR"));
|
||||
extcap_dir = g_strdup(g_getenv(extcap_dir_envar));
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else {
|
||||
|
@ -1255,7 +1307,8 @@ get_persconffile_dir_no_profile(void)
|
|||
/*
|
||||
* See if the user has selected an alternate environment.
|
||||
*/
|
||||
env = g_getenv(ENV_CONFIG_PATH_VAR);
|
||||
const char *config_dir_envar = CONFIGURATION_ENVIRONMENT_VARIABLE("CONFIG_DIR");
|
||||
env = g_getenv(config_dir_envar);
|
||||
#ifdef _WIN32
|
||||
if (env == NULL) {
|
||||
/* for backward compatibility */
|
||||
|
@ -1277,11 +1330,12 @@ get_persconffile_dir_no_profile(void)
|
|||
* is an inaccessible network drive.
|
||||
*/
|
||||
env = g_getenv("APPDATA");
|
||||
const char *persconf_namespace = configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "Wireshark" : "Logwolf";
|
||||
if (env != NULL) {
|
||||
/*
|
||||
* Concatenate %APPDATA% with "\Wireshark".
|
||||
* Concatenate %APPDATA% with "\Wireshark" or "\Logwolf".
|
||||
*/
|
||||
persconffile_dir = g_build_filename(env, "Wireshark", NULL);
|
||||
persconffile_dir = g_build_filename(env, persconf_namespace, NULL);
|
||||
return persconffile_dir;
|
||||
}
|
||||
|
||||
|
@ -1290,14 +1344,14 @@ get_persconffile_dir_no_profile(void)
|
|||
*/
|
||||
env = g_getenv("USERPROFILE");
|
||||
if (env != NULL) {
|
||||
persconffile_dir = g_build_filename(env, "Application Data", "Wireshark", NULL);
|
||||
persconffile_dir = g_build_filename(env, "Application Data", persconf_namespace, NULL);
|
||||
return persconffile_dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Give up and use "C:".
|
||||
*/
|
||||
persconffile_dir = g_build_filename("C:", "Wireshark", NULL);
|
||||
persconffile_dir = g_build_filename("C:", persconf_namespace, NULL);
|
||||
return persconffile_dir;
|
||||
#else
|
||||
char *xdg_path, *path;
|
||||
|
@ -1307,7 +1361,8 @@ get_persconffile_dir_no_profile(void)
|
|||
/*
|
||||
* Check if XDG_CONFIG_HOME/wireshark exists and is a directory.
|
||||
*/
|
||||
xdg_path = g_build_filename(g_get_user_config_dir(), "wireshark", NULL);
|
||||
xdg_path = g_build_filename(g_get_user_config_dir(),
|
||||
CONFIGURATION_NAMESPACE_LOWER, NULL);
|
||||
if (g_file_test(xdg_path, G_FILE_TEST_IS_DIR)) {
|
||||
persconffile_dir = xdg_path;
|
||||
return persconffile_dir;
|
||||
|
@ -1338,7 +1393,9 @@ get_persconffile_dir_no_profile(void)
|
|||
homedir = "/tmp";
|
||||
}
|
||||
}
|
||||
path = g_build_filename(homedir, ".wireshark", NULL);
|
||||
path = g_build_filename(homedir,
|
||||
configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? ".wireshark" : ".logwolf",
|
||||
NULL);
|
||||
if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
|
||||
g_free(xdg_path);
|
||||
persconffile_dir = path;
|
||||
|
|
|
@ -22,13 +22,22 @@ extern "C" {
|
|||
*/
|
||||
#define DEFAULT_PROFILE "Default"
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Initialize our configuration environment.
|
||||
*
|
||||
* Get the pathname of the directory from which the executable came,
|
||||
* and save it for future use. Returns NULL on success, and a
|
||||
* g_mallocated string containing an error on failure.
|
||||
* and save it for future use.
|
||||
*
|
||||
* Set our configuration namespace, which determines the top-level
|
||||
* configuration directory name and environment variable prefixes.
|
||||
* Default is "Wireshark".
|
||||
*
|
||||
* @param arg0 Executable name hint. Should be argv[0].
|
||||
* @param namespace_name The namespace to use. "Wireshark" or NULL uses
|
||||
* the Wireshark namespace. "Logwolf" uses the Logwolf namespace.
|
||||
* @return NULL on success, and a g_mallocated string containing an error on failure.
|
||||
*/
|
||||
WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0);
|
||||
WS_DLL_PUBLIC char *configuration_init(const char *arg0, const char *namespace_name);
|
||||
|
||||
/*
|
||||
* Get the directory in which the program resides.
|
||||
|
@ -37,7 +46,7 @@ WS_DLL_PUBLIC const char *get_progfile_dir(void);
|
|||
|
||||
/*
|
||||
* Get the directory in which plugins are stored; this must not be called
|
||||
* before init_progfile_dir() is called, as they might be stored in a
|
||||
* before configuration_init() is called, as they might be stored in a
|
||||
* subdirectory of the program file directory.
|
||||
*/
|
||||
WS_DLL_PUBLIC const char *get_plugins_dir(void);
|
||||
|
@ -59,7 +68,7 @@ WS_DLL_PUBLIC const char *get_plugins_pers_dir_with_version(void);
|
|||
|
||||
/*
|
||||
* Get the directory in which extcap hooks are stored; this must not be called
|
||||
* before init_progfile_dir() is called, as they might be stored in a
|
||||
* before configuration_init() is called, as they might be stored in a
|
||||
* subdirectory of the program file directory.
|
||||
*/
|
||||
WS_DLL_PUBLIC const char *get_extcap_dir(void);
|
||||
|
|
Loading…
Reference in New Issue