if(WIN32)
- # Linking with setargv.obj enables "wildcard expansion" of
+ # Linking with wsetargv.obj enables "wildcard expansion" of
# command-line arguments.
- set(WILDCARD_OBJ setargv.obj)
+ set(WILDCARD_OBJ wsetargv.obj)
endif(WIN32)
# Banner shown at top right of Qt welcome screen.
}
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
g_string_free(runtime_info_str, TRUE);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return overall_error_status;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
fprintf(stderr, "\n");
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
g_string_free(runtime_info_str, TRUE);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return overall_error_status;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
}
/* And now our feature presentation... [ fade to music ] */
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
g_string_free(runtime_info_str, TRUE);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
/*
return 0; /* never here, make compiler happy */
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
static void
console_log_handler(const char *log_domain, GLogLevelFlags log_level,
return pdh;
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return ret;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/* Skip meta-information read from file to return offset of real
* protocol data */
static int
return FALSE;
}
-
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
cmdarg_err_init(mergecap_cmdarg_err, mergecap_cmdarg_err_cont);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return (status == MERGE_OK) ? 0 : 2;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
-
fprintf(output, "\nIf type is not specified, a random packet will be chosen\n\n");
}
-int
-main(int argc, char **argv)
+static int
+real_main(int argc, char **argv)
{
char *init_progfile_dir_error;
int opt;
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return ret;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t **argv)
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char **argv)
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
return FALSE;
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return ret;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/**
* Read data from a raw pipe. The "raw" data consists of a libpcap
* packet header followed by the payload.
};
struct tm *now_tm;
-#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
- create_app_running_mutex();
-#endif /* _WIN32 */
-
/* Get the compile-time version information string */
comp_info_str = get_compiled_version_info(NULL, NULL);
return EXIT_SUCCESS;
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
+#ifdef _WIN32
+ create_app_running_mutex();
+#endif /* _WIN32 */
+
if (parse_options(argc, argv) != EXIT_SUCCESS) {
ret = EXIT_FAILURE;
goto clean_exit;
return ret;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
-
epan_get_runtime_version_info(str);
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return exit_status;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
static const nstime_t *
tfshark_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num)
{
tap_listeners_require_dissection() || dissect_color;
}
-int
-main(int argc, char *argv[])
+static int
+real_main(int argc, char *argv[])
{
GString *comp_info_str;
GString *runtime_info_str;
cmdarg_err_init(failure_warning_message, failure_message_cont);
#ifdef _WIN32
- arg_list_utf_16to8(argc, argv);
create_app_running_mutex();
#endif /* _WIN32 */
return exit_status;
}
+#ifdef _WIN32
+int
+wmain(int argc, wchar_t *argv[])
+{
+ char **argv_utf8;
+
+ /* Convert our arg list from UTF-16LE to UTF-8. */
+ argv_utf8 = g_malloc(argc * sizeof *argv_utf8);
+ for (int i = 0; i < argc; i++)
+ argv_utf8[i] = g_utf16_to_utf8(argv[i], -1, NULL, NULL, NULL);
+ return real_main(argc, argv_utf8);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ return real_main(argc, argv);
+}
+#endif
+
/*#define USE_BROKEN_G_MAIN_LOOP*/
#ifdef USE_BROKEN_G_MAIN_LOOP
#include <locale.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <tchar.h>
+#include <wchar.h>
+#include <shellapi.h>
+#endif
+
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _WIN32
# include "caputils/capture-wpcap.h"
# include "caputils/capture_wpcap_packet.h"
-# include <tchar.h> /* Needed for Unicode */
# include <wsutil/file_util.h>
#endif /* _WIN32 */
#ifdef _WIN32
int opt;
+ LPWSTR *wc_argv;
+ int wc_argc;
#endif
int ret_val = EXIT_SUCCESS;
char **argv = qt_argv;
setlocale(LC_ALL, "");
#ifdef _WIN32
- // QCoreApplication clobbers argv. Let's have a local copy.
- argv = (char **) g_malloc(sizeof(char *) * argc);
- for (opt = 0; opt < argc; opt++) {
- argv[opt] = qt_argv[opt];
- }
- arg_list_utf_16to8(argc, argv);
+ //
+ // On Windows, QCoreApplication has its own WinMain(), which gets the
+ // command line using GetCommandLineW(), breaks it into individual
+ // arguments using CommandLineToArgvW(), and then "helpfully"
+ // converts those UTF-16LE arguments into strings in the local code
+ // page.
+ //
+ // We don't want that, because not all file names can be represented
+ // in the local code page, so we do the same, but we convert the
+ // strings into UTF-8.
+ //
+ wc_argv = CommandLineToArgvW(GetCommandLineW(), &wc_argc);
+ if (wc_argv && wc_argc == argc) {
+ argv = (char **) g_malloc(sizeof(char *) * argc);
+ for (opt = 0; opt < argc; opt++) {
+ argv[opt] = g_utf16_to_utf8((const gunichar2 *)wc_argv[opt], -1, NULL, NULL, NULL);
+ }
+ } /* XXX else bail because something is horribly, horribly wrong? */
+ LocalFree(wc_argv);
+
create_app_running_mutex();
#endif /* _WIN32 */
#ifdef _WIN32
-#include <shellapi.h>
#include <strsafe.h>
/** @file
return utf8buf[idx];
}
-
-/* Convert our argument list from UTF-16 to UTF-8. */
-void
-arg_list_utf_16to8(int argc, char *argv[]) {
- LPWSTR *wc_argv;
- int wc_argc, i;
-
- /* Convert our arg list to UTF-8. */
- wc_argv = CommandLineToArgvW(GetCommandLineW(), &wc_argc);
- if (wc_argv && wc_argc == argc) {
- for (i = 0; i < argc; i++) {
- argv[i] = g_utf16_to_utf8(wc_argv[i], -1, NULL, NULL, NULL);
- }
- } /* XXX else bail because something is horribly, horribly wrong? */
- LocalFree(wc_argv);
-}
-
#endif
/*
*/
WS_DLL_PUBLIC
gchar * utf_16to8(const wchar_t *utf16str);
-
-/** Convert the program argument list from UTF-16 to UTF-8 and
- * store it in the supplied array. This is intended to be used
- * to normalize command line arguments at program startup.
- *
- * @param argc The number of arguments. You should simply pass the
- * first argument from main().
- * @param argv The argument values (vector). You should simply pass
- * the second argument from main().
- */
-WS_DLL_PUBLIC
-void arg_list_utf_16to8(int argc, char *argv[]);
-
-
#endif /* _WIN32 */
/*