forked from osmocom/wireshark
Just have init_progfile_dir() take a void pointer.
dladdr() takes a void * as a code pointer; have init_progfile_dir() do so, and do the casting in the calls. We don't care about the signature of the function whose address we're passing, we just want to pass a pointer to *something* in the main program. Change-Id: I9372620a97b0eb53c2bb3c0c41a238b4408f3709 Reviewed-on: https://code.wireshark.org/review/7270 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
ec6ec49941
commit
9423a13b2d
|
@ -1164,7 +1164,7 @@ main(int argc, char *argv[])
|
||||||
init_open_routines();
|
init_open_routines();
|
||||||
|
|
||||||
#ifdef HAVE_PLUGINS
|
#ifdef HAVE_PLUGINS
|
||||||
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
|
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
|
||||||
g_warning("capinfos: init_progfile_dir(): %s", init_progfile_dir_error);
|
g_warning("capinfos: init_progfile_dir(): %s", init_progfile_dir_error);
|
||||||
g_free(init_progfile_dir_error);
|
g_free(init_progfile_dir_error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -168,7 +168,7 @@ main(int argc, char *argv[])
|
||||||
init_open_routines();
|
init_open_routines();
|
||||||
|
|
||||||
#ifdef HAVE_PLUGINS
|
#ifdef HAVE_PLUGINS
|
||||||
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
|
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
|
||||||
g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
|
g_warning("captype: init_progfile_dir(): %s", init_progfile_dir_error);
|
||||||
g_free(init_progfile_dir_error);
|
g_free(init_progfile_dir_error);
|
||||||
} else {
|
} else {
|
||||||
|
|
2
dftest.c
2
dftest.c
|
@ -70,7 +70,7 @@ main(int argc, char **argv)
|
||||||
/*
|
/*
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
|
||||||
if (init_progfile_dir_error != NULL) {
|
if (init_progfile_dir_error != NULL) {
|
||||||
fprintf(stderr, "dftest: Can't get pathname of dftest program: %s.\n",
|
fprintf(stderr, "dftest: Can't get pathname of dftest program: %s.\n",
|
||||||
init_progfile_dir_error);
|
init_progfile_dir_error);
|
||||||
|
|
|
@ -474,7 +474,7 @@ static void preinit_epan(char* argv0, int (*main)(int, char **)) {
|
||||||
int dp_open_errno, dp_read_errno;
|
int dp_open_errno, dp_read_errno;
|
||||||
char* error;
|
char* error;
|
||||||
|
|
||||||
error = init_progfile_dir(argv0, main);
|
error = init_progfile_dir(argv0, (void *)main);
|
||||||
|
|
||||||
comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
|
comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
|
||||||
|
|
||||||
|
|
|
@ -944,7 +944,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifdef HAVE_PLUGINS
|
#ifdef HAVE_PLUGINS
|
||||||
/* Register wiretap plugins */
|
/* Register wiretap plugins */
|
||||||
if ((init_progfile_dir_error = init_progfile_dir(argv[0], main))) {
|
if ((init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main))) {
|
||||||
g_warning("editcap: init_progfile_dir(): %s", init_progfile_dir_error);
|
g_warning("editcap: init_progfile_dir(): %s", init_progfile_dir_error);
|
||||||
g_free(init_progfile_dir_error);
|
g_free(init_progfile_dir_error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -495,7 +495,7 @@ main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
|
||||||
if (init_progfile_dir_error != NULL) {
|
if (init_progfile_dir_error != NULL) {
|
||||||
fprintf(stderr, "rawshark: Can't get pathname of rawshark program: %s.\n",
|
fprintf(stderr, "rawshark: Can't get pathname of rawshark program: %s.\n",
|
||||||
init_progfile_dir_error);
|
init_progfile_dir_error);
|
||||||
|
|
|
@ -846,7 +846,7 @@ main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
|
||||||
if (init_progfile_dir_error != NULL) {
|
if (init_progfile_dir_error != NULL) {
|
||||||
fprintf(stderr, "tfshark: Can't get pathname of tfshark program: %s.\n",
|
fprintf(stderr, "tfshark: Can't get pathname of tfshark program: %s.\n",
|
||||||
init_progfile_dir_error);
|
init_progfile_dir_error);
|
||||||
|
|
2
tshark.c
2
tshark.c
|
@ -1047,7 +1047,7 @@ main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
|
||||||
if (init_progfile_dir_error != NULL) {
|
if (init_progfile_dir_error != NULL) {
|
||||||
fprintf(stderr, "tshark: Can't get pathname of tshark program: %s.\n",
|
fprintf(stderr, "tshark: Can't get pathname of tshark program: %s.\n",
|
||||||
init_progfile_dir_error);
|
init_progfile_dir_error);
|
||||||
|
|
|
@ -2207,7 +2207,7 @@ main(int argc, char *argv[])
|
||||||
/*
|
/*
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
init_progfile_dir_error = init_progfile_dir(argv[0], (void *)main);
|
||||||
|
|
||||||
/* initialize the funnel mini-api */
|
/* initialize the funnel mini-api */
|
||||||
initialize_funnel_ops();
|
initialize_funnel_ops();
|
||||||
|
|
|
@ -483,7 +483,7 @@ int main(int argc, char *argv[])
|
||||||
* Attempt to get the pathname of the executable file.
|
* Attempt to get the pathname of the executable file.
|
||||||
*/
|
*/
|
||||||
/* init_progfile_dir_error = */ init_progfile_dir(argv[0],
|
/* init_progfile_dir_error = */ init_progfile_dir(argv[0],
|
||||||
(progfile_main_t) get_gui_compiled_info);
|
(void *) get_gui_compiled_info);
|
||||||
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
|
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
|
||||||
|
|
||||||
/* Get the compile-time version information string */
|
/* Get the compile-time version information string */
|
||||||
|
|
|
@ -479,7 +479,7 @@ init_progfile_dir(const char *arg0
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
_U_
|
_U_
|
||||||
#endif
|
#endif
|
||||||
, progfile_main_t main_addr
|
, void *function_addr
|
||||||
#if defined(_WIN32) || !defined(HAVE_DLADDR)
|
#if defined(_WIN32) || !defined(HAVE_DLADDR)
|
||||||
_U_
|
_U_
|
||||||
#endif
|
#endif
|
||||||
|
@ -575,7 +575,7 @@ init_progfile_dir(const char *arg0
|
||||||
|
|
||||||
execname = get_executable_path();
|
execname = get_executable_path();
|
||||||
#ifdef HAVE_DLADDR
|
#ifdef HAVE_DLADDR
|
||||||
if (main_addr != NULL && execname == NULL) {
|
if (function_addr != NULL && execname == NULL) {
|
||||||
/*
|
/*
|
||||||
* Try to use dladdr() to find the pathname of the executable.
|
* Try to use dladdr() to find the pathname of the executable.
|
||||||
* dladdr() is not guaranteed to give you anything better than
|
* dladdr() is not guaranteed to give you anything better than
|
||||||
|
@ -585,7 +585,7 @@ init_progfile_dir(const char *arg0
|
||||||
* path and obviate the need for us to determine the absolute
|
* path and obviate the need for us to determine the absolute
|
||||||
* path.
|
* path.
|
||||||
*/
|
*/
|
||||||
if (dladdr((void *)main_addr, &info))
|
if (dladdr(function_addr, &info))
|
||||||
execname = info.dli_fname;
|
execname = info.dli_fname;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,8 +40,7 @@ extern "C" {
|
||||||
* and save it for future use. Returns NULL on success, and a
|
* and save it for future use. Returns NULL on success, and a
|
||||||
* g_mallocated string containing an error on failure.
|
* g_mallocated string containing an error on failure.
|
||||||
*/
|
*/
|
||||||
typedef int (*progfile_main_t)(int, char **);
|
WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0, void *function_addr);
|
||||||
WS_DLL_PUBLIC char *init_progfile_dir(const char *arg0, progfile_main_t main_addr);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the directory in which the program resides.
|
* Get the directory in which the program resides.
|
||||||
|
|
Loading…
Reference in New Issue