cli_main: remove real_main from stack traces for non-Windows
Restore the "main" name since that is used everywhere else except for Windows. On Windows, "main" is renamed via a macro to avoid a conflict with "wmain" and to allow it to be called in cli_main.c. For those wondering, GUI applications (such as Qt) have a different entry point, namely WinMain. In Qt5, src/winmain/qtmain_win.cpp defines WinMain, but seems to convert its arguments from Unicode to CP_ACP (ASCII). It might not support UTF-8, but I did not verify this. Change-Id: I93fa59324eb2ef95a305b08fc5ba34d49cc73bf0 Reviewed-on: https://code.wireshark.org/review/31208 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
974969cd06
commit
e2e5b01d77
|
@ -1400,7 +1400,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
wtap *wth;
|
wtap *wth;
|
||||||
|
|
|
@ -78,7 +78,7 @@ failure_message_cont(const char *msg_format, va_list ap)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
wtap *wth;
|
wtap *wth;
|
||||||
|
|
15
cli_main.c
15
cli_main.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Compile and link this with all CLI programs where the main routine
|
* Compile and link this with all CLI programs where the main routine
|
||||||
* should get UTF-8 arguments on Windows. In those programs, declare
|
* should get UTF-8 arguments on Windows. In those programs, include the
|
||||||
* the main program as real_main() rather than main().
|
* cli_main.h header to rename main to real_main on Windows.
|
||||||
*
|
*
|
||||||
* This is used in software licensed under the GPLv2, and its license MUST
|
* This is used in software licensed under the GPLv2, and its license MUST
|
||||||
* be compatible with that license.
|
* be compatible with that license.
|
||||||
|
@ -62,12 +62,11 @@ wmain(int argc, wchar_t *wc_argv[])
|
||||||
argv[i] = utf8_string;
|
argv[i] = utf8_string;
|
||||||
}
|
}
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
return real_main(argc, argv);
|
/*
|
||||||
}
|
* The original "main" routine was renamed to "real_main" via a macro in
|
||||||
#else /* _WIN32 */
|
* the cli_main.h header file since either "main" or "wmain" can be
|
||||||
int
|
* defined on Windows, but not both.
|
||||||
main(int argc, char *argv[])
|
*/
|
||||||
{
|
|
||||||
return real_main(argc, argv);
|
return real_main(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
10
cli_main.h
10
cli_main.h
|
@ -1,9 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Declaration of the real main routine, for all CLI programs where the
|
* Declaration of the real main routine, for all CLI programs where the
|
||||||
* main routine should get UTF-8 arguments on Windows. In those programs,
|
* main routine should get UTF-8 arguments on Windows. In those programs,
|
||||||
* in the file that defines the main routine, include this header and define
|
* in the file that defines the main routine, include this header and link
|
||||||
* the main routine as real_main() rather than main(), and build those
|
* those programs with cli_main.c.
|
||||||
* programs with cli_main.c and link with the object file.
|
|
||||||
*
|
*
|
||||||
* This is used in software licensed under the GPLv2, and its license MUST
|
* This is used in software licensed under the GPLv2, and its license MUST
|
||||||
* be compatible with that license.
|
* be compatible with that license.
|
||||||
|
@ -16,4 +15,7 @@
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int real_main(int argc, char *argv[]);
|
#ifdef _WIN32
|
||||||
|
int real_main(int argc, char *argv[]);
|
||||||
|
#define main real_main
|
||||||
|
#endif
|
||||||
|
|
|
@ -4656,7 +4656,7 @@ get_dumpcap_runtime_info(GString *str)
|
||||||
|
|
||||||
/* And now our feature presentation... [ fade to music ] */
|
/* And now our feature presentation... [ fade to music ] */
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
|
|
|
@ -982,7 +982,7 @@ editcap_dump_open(const char *filename, const wtap_dump_params *params,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
wtap *wth = NULL;
|
wtap *wth = NULL;
|
||||||
|
|
|
@ -2480,7 +2480,7 @@ static int capture_android_tcpdump(char *interface, char *fifo,
|
||||||
return EXIT_CODE_SUCCESS;
|
return EXIT_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int real_main(int argc, char **argv) {
|
int main(int argc, char *argv[]) {
|
||||||
int ret = EXIT_CODE_GENERIC;
|
int ret = EXIT_CODE_GENERIC;
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
int result;
|
int result;
|
||||||
|
|
|
@ -515,7 +515,7 @@ static int list_config(char *interface, unsigned int remote_port)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int real_main(int argc, char **argv)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
|
|
|
@ -121,7 +121,7 @@ static int list_config(char *interface)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int real_main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
int result;
|
int result;
|
||||||
|
|
|
@ -329,7 +329,7 @@ static char* concat_filters(const char* extcap_filter, const char* remote_filter
|
||||||
return g_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter);
|
return g_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int real_main(int argc, char **argv)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
|
|
|
@ -356,7 +356,7 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto
|
||||||
g_free(buf);
|
g_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int real_main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
int result;
|
int result;
|
||||||
|
|
|
@ -227,7 +227,7 @@ merge_callback(merge_event event, int num,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
|
@ -100,7 +100,7 @@ usage(gboolean is_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char **argv)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
|
@ -403,7 +403,7 @@ set_link_type(const char *lt_arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
int opt, i;
|
int opt, i;
|
||||||
|
|
|
@ -161,7 +161,7 @@ failure_message_cont(const char *msg_format, va_list ap)
|
||||||
/* Main function. */
|
/* Main function. */
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
wtap *wth = NULL;
|
wtap *wth = NULL;
|
||||||
|
|
|
@ -1853,7 +1853,7 @@ parse_options (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,7 @@ get_tfshark_runtime_version_info(GString *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
real_main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
Loading…
Reference in New Issue