From a34cc98b2ac5a0ad011a1c3a40ce5e59230a9498 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 12 Dec 2018 02:53:08 -0800 Subject: Put the main() and wmain() routines for CLI programs into a separate file. That means that code is only in one place, rather than having copies of it in each of those programs. CLI programs that, on Windows, should get UTF-8 arguments rather than arguments in the local code page should: include the top-level cli_main.h header; define the main function as real_main(); be built with the top-level cli_main.c file. On UN*X, cli_main.c has a main() program, and just passes the arguments on to real_main(). On Windows, cli_main.c has a wmain() function that converts the UTF-16 arguments it's handed to UTF-8 arguments, using WideCharToMultiByte() so that it doesn't use any functions other than those provided by the system, and then calls real_main() with the argument count and UTF-8 arguments. Change-Id: I8b11f01dbc5c63fce599d1bef9ad96cd92c3c01e Reviewed-on: https://code.wireshark.org/review/31017 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- capinfos.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'capinfos.c') diff --git a/capinfos.c b/capinfos.c index ddcf1f5633..0b06e42207 100644 --- a/capinfos.c +++ b/capinfos.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -80,10 +81,6 @@ #include "wsutil/wsgetopt.h" #endif -#ifdef _WIN32 -#include -#endif /* _WIN32 */ - #include "ui/failure_message.h" #define INVALID_OPTION 1 @@ -1403,7 +1400,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) { } } -static int +int real_main(int argc, char *argv[]) { GString *comp_info_str; @@ -1730,23 +1727,6 @@ exit: return overall_error_status; } -#ifdef _WIN32 -int -wmain(int argc, wchar_t *wc_argv[]) -{ - char **argv; - - argv = arg_list_utf_16to8(argc, wc_argv); - return real_main(argc, argv); -} -#else -int -main(int argc, char *argv[]) -{ - return real_main(argc, argv); -} -#endif - /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * -- cgit v1.2.1