size_t fileLength;
const char * str;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
tr_formatter_mem_init (MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR);
tr_formatter_size_init (DISK_K,DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR);
tr_formatter_speed_init (SPEED_K, SPEED_K_STR, SPEED_M_STR, SPEED_G_STR, SPEED_T_STR);
tr_session * session = NULL;
struct event *status_ev;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
key_pidfile = tr_quark_new ("pidfile", 7);
signal (SIGINT, gotsig);
char * rpcurl = NULL;
int exit_status = EXIT_SUCCESS;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
if (argc < 2) {
showUsage ();
return EXIT_FAILURE;
#include <w32api.h>
#define WINVER WindowsXP /* freeaddrinfo (), getaddrinfo (), getnameinfo () */
#include <windows.h> /* Sleep (), GetSystemTimeAsFileTime (), GetEnvironmentVariable () */
+ #include <shellapi.h> /* CommandLineToArgv () */
#endif
#include "transmission.h"
return text;
}
+void
+tr_win32_make_args_utf8 (int * argc,
+ char *** argv)
+{
+ int my_argc, i;
+ char ** my_argv;
+ wchar_t ** my_wide_argv;
+
+ my_wide_argv = CommandLineToArgvW (GetCommandLineW (), &my_argc);
+ if (my_wide_argv == NULL)
+ return;
+
+ assert (*argc == my_argc);
+
+ my_argv = tr_new (char *, my_argc + 1);
+
+ for (i = 0; i < my_argc; ++i)
+ {
+ my_argv[i] = tr_win32_native_to_utf8 (my_wide_argv[i], -1);
+ if (my_argv[i] == NULL)
+ break;
+ }
+
+ if (i < my_argc)
+ {
+ int j;
+
+ for (j = 0; j < i; ++j)
+ {
+ tr_free (my_argv[j]);
+ }
+
+ tr_free (my_argv);
+ }
+ else
+ {
+ my_argv[my_argc] = NULL;
+
+ *argc = my_argc;
+ *argv = my_argv;
+
+ /* TODO: Add atexit handler to cleanup? */
+ }
+
+ LocalFree (my_wide_argv);
+}
+
#endif
/***
int extra_chars);
char * tr_win32_format_message (uint32_t code);
+void tr_win32_make_args_utf8 (int * argc,
+ char *** argv);
+
#endif
/***
int c;
QStringList addme;
const char * optarg;
- char ** argvv = argv;
+ char ** argvv;
+
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
+ argvv = argv;
while ( (c = tr_getopt (getUsage (), argc, (const char **)argvv, opts, &optarg)))
if (c == TR_OPT_UNK)
addme.append (optarg);
char * out2 = NULL;
tr_metainfo_builder * b = NULL;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
tr_logSetLevel (TR_LOG_ERROR);
tr_formatter_mem_init (MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR);
tr_formatter_size_init (DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR);
int i;
int changedCount = 0;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
files = tr_new0 (const char*, argc);
tr_logSetLevel (TR_LOG_ERROR);
tr_info inf;
tr_ctor * ctor;
+#ifdef _WIN32
+ tr_win32_make_args_utf8 (&argc, &argv);
+#endif
+
tr_logSetLevel (TR_LOG_ERROR);
tr_formatter_mem_init (MEM_K, MEM_K_STR, MEM_M_STR, MEM_G_STR, MEM_T_STR);
tr_formatter_size_init (DISK_K, DISK_K_STR, DISK_M_STR, DISK_G_STR, DISK_T_STR);