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>
thomas/dect
Peter Wu 4 years ago committed by Anders Broman
parent 974969cd06
commit e2e5b01d77
  1. 2
      capinfos.c
  2. 2
      captype.c
  3. 15
      cli_main.c
  4. 10
      cli_main.h
  5. 2
      dumpcap.c
  6. 2
      editcap.c
  7. 2
      extcap/androiddump.c
  8. 2
      extcap/ciscodump.c
  9. 2
      extcap/randpktdump.c
  10. 2
      extcap/sshdump.c
  11. 2
      extcap/udpdump.c
  12. 2
      mergecap.c
  13. 2
      randpkt.c
  14. 2
      rawshark.c
  15. 2
      reordercap.c
  16. 2
      text2pcap.c
  17. 2
      tfshark.c
  18. 2
      tshark.c

@ -1400,7 +1400,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
wtap *wth;

@ -78,7 +78,7 @@ failure_message_cont(const char *msg_format, va_list ap)
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
wtap *wth;

@ -1,7 +1,7 @@
/*
* Compile and link this with all CLI programs where the main routine
* should get UTF-8 arguments on Windows. In those programs, declare
* the main program as real_main() rather than main().
* should get UTF-8 arguments on Windows. In those programs, include the
* 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
* be compatible with that license.
@ -62,12 +62,11 @@ wmain(int argc, wchar_t *wc_argv[])
argv[i] = utf8_string;
}
argv[i] = NULL;
return real_main(argc, argv);
}
#else /* _WIN32 */
int
main(int argc, char *argv[])
{
/*
* The original "main" routine was renamed to "real_main" via a macro in
* the cli_main.h header file since either "main" or "wmain" can be
* defined on Windows, but not both.
*/
return real_main(argc, argv);
}
#endif

@ -1,9 +1,8 @@
/*
* Declaration of the real main routine, for all CLI programs where the
* 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
* the main routine as real_main() rather than main(), and build those
* programs with cli_main.c and link with the object file.
* in the file that defines the main routine, include this header and link
* those programs with cli_main.c.
*
* This is used in software licensed under the GPLv2, and its license MUST
* be compatible with that license.
@ -16,4 +15,7 @@
* 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 ] */
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
int opt;
static const struct option long_options[] = {

@ -982,7 +982,7 @@ editcap_dump_open(const char *filename, const wtap_dump_params *params,
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
wtap *wth = NULL;

@ -2480,7 +2480,7 @@ static int capture_android_tcpdump(char *interface, char *fifo,
return EXIT_CODE_SUCCESS;
}
int real_main(int argc, char **argv) {
int main(int argc, char *argv[]) {
int ret = EXIT_CODE_GENERIC;
int option_idx = 0;
int result;

@ -515,7 +515,7 @@ static int list_config(char *interface, unsigned int remote_port)
return EXIT_SUCCESS;
}
int real_main(int argc, char **argv)
int main(int argc, char *argv[])
{
int result;
int option_idx = 0;

@ -121,7 +121,7 @@ static int list_config(char *interface)
return EXIT_SUCCESS;
}
int real_main(int argc, char *argv[])
int main(int argc, char *argv[])
{
int option_idx = 0;
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);
}
int real_main(int argc, char **argv)
int main(int argc, char *argv[])
{
int result;
int option_idx = 0;

@ -356,7 +356,7 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto
g_free(buf);
}
int real_main(int argc, char *argv[])
int main(int argc, char *argv[])
{
int option_idx = 0;
int result;

@ -227,7 +227,7 @@ merge_callback(merge_event event, int num,
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt;

@ -100,7 +100,7 @@ usage(gboolean is_error)
}
int
real_main(int argc, char **argv)
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt;

@ -403,7 +403,7 @@ set_link_type(const char *lt_arg) {
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt, i;

@ -161,7 +161,7 @@ failure_message_cont(const char *msg_format, va_list ap)
/* Main function. */
/********************************************************************/
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
wtap *wth = NULL;

@ -1853,7 +1853,7 @@ parse_options (int argc, char *argv[])
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;

@ -300,7 +300,7 @@ get_tfshark_runtime_version_info(GString *str)
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt;

@ -670,7 +670,7 @@ must_do_dissection(dfilter_t *rfcode, dfilter_t *dfcode,
}
int
real_main(int argc, char *argv[])
main(int argc, char *argv[])
{
char *init_progfile_dir_error;
int opt;

Loading…
Cancel
Save