summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arm/gnunet-arm.c3
-rw-r--r--src/ats/perf_ats_mlp.c2
-rw-r--r--src/chat/gnunet-chat.c4
-rw-r--r--src/core/gnunet-core.c4
-rw-r--r--src/dht/gnunet-dht-get.c4
-rw-r--r--src/dht/gnunet-dht-monitor.c3
-rw-r--r--src/dht/gnunet-dht-put.c3
-rw-r--r--src/dns/gnunet-dns-monitor.c4
-rw-r--r--src/dns/gnunet-dns-redirector.c4
-rw-r--r--src/exit/gnunet-daemon-exit.c3
-rw-r--r--src/fs/gnunet-directory.c4
-rw-r--r--src/fs/gnunet-download.c4
-rw-r--r--src/fs/gnunet-fs.c4
-rw-r--r--src/fs/gnunet-helper-fs-publish.c5
-rw-r--r--src/fs/gnunet-pseudonym.c4
-rw-r--r--src/fs/gnunet-publish.c4
-rw-r--r--src/fs/gnunet-search.c4
-rw-r--r--src/fs/gnunet-unindex.c4
-rw-r--r--src/gns/gnunet-gns-fcfsd.c3
-rw-r--r--src/gns/gnunet-gns-lookup.c3
-rw-r--r--src/gns/gnunet-gns-proxy.c3
-rw-r--r--src/gns/gnunet-gns.c3
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c3
-rw-r--r--src/include/gnunet_strings_lib.h18
-rw-r--r--src/integration-tests/connection_watchdog.c4
-rw-r--r--src/namestore/gnunet-namestore.c3
-rw-r--r--src/nat/gnunet-nat-server.c3
-rw-r--r--src/nse/gnunet-nse-profiler.c5
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c4
-rw-r--r--src/pt/gnunet-daemon-pt.c3
-rw-r--r--src/statistics/gnunet-statistics.c4
-rw-r--r--src/template/gnunet-template.c4
-rw-r--r--src/testing_old/gnunet-testing.c4
-rw-r--r--src/topology/gnunet-daemon-topology.c3
-rw-r--r--src/transport/gnunet-transport.c4
-rw-r--r--src/util/gnunet-resolver.c4
-rw-r--r--src/util/gnunet-rsa.c4
-rw-r--r--src/util/program.c1
-rw-r--r--src/util/strings.c90
-rw-r--r--src/vpn/gnunet-vpn.c4
40 files changed, 242 insertions, 2 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index 58aa70957..744c3f208 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -431,6 +431,9 @@ main (int argc, char *const *argv)
if (temp_timeout_ms > 0)
timeout.rel_value = temp_timeout_ms;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
if (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-arm",
gettext_noop
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index b9ee5e4dc..ff2d8dada 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -360,6 +360,8 @@ main (int argc, char *argv[])
GNUNET_GETOPT_OPTION_END
};
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
GNUNET_PROGRAM_run (argc, argv,
"perf_ats_mlp", "nohelp", options,
diff --git a/src/chat/gnunet-chat.c b/src/chat/gnunet-chat.c
index 7b11c0d18..012f78ed9 100644
--- a/src/chat/gnunet-chat.c
+++ b/src/chat/gnunet-chat.c
@@ -737,6 +737,10 @@ main (int argc, char *const *argv)
flags |= O_NONBLOCK;
fcntl (0, F_SETFL, flags);
#endif
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-chat",
gettext_noop ("Join a chat on GNUnet."), options,
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 4fe0a4f86..78bc14154 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -89,6 +89,10 @@ main (int argc, char *const *argv)
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-core",
gettext_noop
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index fb185c489..7555f9009 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -226,6 +226,10 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
int
main (int argc, char *const *argv)
{
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get",
gettext_noop
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c
index 8ca3beb2a..088874a53 100644
--- a/src/dht/gnunet-dht-monitor.c
+++ b/src/dht/gnunet-dht-monitor.c
@@ -315,6 +315,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
int
main (int argc, char *const *argv)
{
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get",
gettext_noop
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index 59acc792b..f6409bdff 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -217,6 +217,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
int
main (int argc, char *const *argv)
{
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-put",
gettext_noop
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index 82715aabc..2a05efdee 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -342,6 +342,10 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-dns-monitor",
gettext_noop
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c
index a45b89609..5ba7e87c6 100644
--- a/src/dns/gnunet-dns-redirector.c
+++ b/src/dns/gnunet-dns-redirector.c
@@ -241,6 +241,10 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-dns-redirector",
gettext_noop
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 26f3e7536..216625567 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -3230,6 +3230,9 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_END
};
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-exit",
gettext_noop
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index c722f57ff..4122cb154 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -173,6 +173,10 @@ main (int argc, char *const *argv)
static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-directory [OPTIONS] FILENAME",
gettext_noop
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 5a66aea27..bd5b09c0d 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -272,6 +272,10 @@ main (int argc, char *const *argv)
0, &GNUNET_GETOPT_increment_value, &verbose},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-download [OPTIONS] URI",
gettext_noop
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 0b2892371..404c64e4d 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -119,6 +119,10 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
gettext_noop ("Special file-sharing operations"),
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index 86b02492d..45f6d588d 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -413,7 +413,7 @@ extract_files (struct ScanTreeNode *item)
* @return 0 on success
*/
int main(int argc,
- char **argv)
+ char *const *argv)
{
const char *filename_expanded;
const char *ex;
@@ -424,6 +424,9 @@ int main(int argc,
* binary mode.
*/
_setmode (1, _O_BINARY);
+ /* Get utf-8-encoded arguments */
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 5;
#endif
/* parse command line */
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
index 38826d1de..2b1b897c2 100644
--- a/src/fs/gnunet-pseudonym.c
+++ b/src/fs/gnunet-pseudonym.c
@@ -313,6 +313,10 @@ main (int argc, char *const *argv)
};
bo.expiration_time =
GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-pseudonym [OPTIONS]",
gettext_noop ("Manage GNUnet pseudonyms."),
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index a1b26dbd5..24e49d369 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -736,6 +736,10 @@ main (int argc, char *const *argv)
"GNUnet publish starts\n");
bo.expiration_time =
GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-publish [OPTIONS] FILENAME",
gettext_noop
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 60620a4b3..88507f608 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -302,6 +302,10 @@ main (int argc, char *const *argv)
1, &GNUNET_GETOPT_set_uint, &results_limit},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD",
gettext_noop
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index 3e8308df2..f4e352737 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -170,6 +170,10 @@ main (int argc, char *const *argv)
0, &GNUNET_GETOPT_set_one, &verbose},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-unindex [OPTIONS] FILENAME",
gettext_noop
diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c
index cd4e8e72d..b919b4fed 100644
--- a/src/gns/gnunet-gns-fcfsd.c
+++ b/src/gns/gnunet-gns-fcfsd.c
@@ -797,6 +797,9 @@ main (int argc, char *const *argv)
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("fcfsd", "WARNING", NULL);
ret =
(GNUNET_OK ==
diff --git a/src/gns/gnunet-gns-lookup.c b/src/gns/gnunet-gns-lookup.c
index f33264f61..bcd2b5bcc 100644
--- a/src/gns/gnunet-gns-lookup.c
+++ b/src/gns/gnunet-gns-lookup.c
@@ -204,6 +204,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
int
main (int argc, char *const *argv)
{
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-gns-get",
gettext_noop
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index b35cacad0..2fef34343 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -2320,6 +2320,9 @@ main (int argc, char *const *argv)
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL);
ret =
(GNUNET_OK ==
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 2a49ba1c2..1efe74842 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -248,6 +248,9 @@ main (int argc, char *const *argv)
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("gnunet-gns", "WARNING", NULL);
ret =
(GNUNET_OK ==
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 8b7bf3a3e..6637f37ce 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -334,6 +334,9 @@ main (int argc, char *const *argv)
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("hostlist", "WARNING", NULL);
ret =
(GNUNET_OK ==
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 54d2e3034..d68ca5c78 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -390,6 +390,24 @@ GNUNET_STRINGS_to_address_ip (const char *addr,
struct sockaddr_storage *r_buf);
+/**
+ * Returns utf-8 encoded arguments.
+ * Does nothing (returns a copy of argc and argv) on any platform
+ * other than W32.
+ * Returned argv has u8argv[u8argc] == NULL.
+ * Returned argv is a single memory block, and can be freed with a single
+ * GNUNET_free () call.
+ *
+ * @param argc argc (as given by main())
+ * @param argv argv (as given by main())
+ * @param u8argc a location to store new argc in (though it's th same as argc)
+ * @param u8argv a location to store new argv in
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int
+GNUNET_STRINGS_get_utf8_args (int argc, char *const *argv, int *u8argc,
+ char *const **u8argv);
+
/* ifndef GNUNET_UTIL_STRING_H */
#endif
/* end of gnunet_util_string.h */
diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c
index a06b5a763..bcf9d0379 100644
--- a/src/integration-tests/connection_watchdog.c
+++ b/src/integration-tests/connection_watchdog.c
@@ -1090,6 +1090,10 @@ main (int argc, char *const *argv)
GNUNET_NO, &GNUNET_GETOPT_set_one, &ping},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "cn",
gettext_noop ("help text"), options, &run,
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index a0d1de10a..624981201 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -493,6 +493,9 @@ main (int argc, char *const *argv)
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
ret =
(GNUNET_OK ==
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c
index 9b6846cf0..e971bd3b1 100644
--- a/src/nat/gnunet-nat-server.c
+++ b/src/nat/gnunet-nat-server.c
@@ -313,6 +313,9 @@ main (int argc, char *const argv[])
GNUNET_GETOPT_OPTION_END
};
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv, "gnunet-nat-server [options] PORT",
_("GNUnet NAT traversal test helper daemon"), options,
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c
index 4a4bea5ed..cf88690d5 100644
--- a/src/nse/gnunet-nse-profiler.c
+++ b/src/nse/gnunet-nse-profiler.c
@@ -914,8 +914,11 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
int
-main (int argc, char *argv[])
+main (int argc, char *const *argv)
{
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
GNUNET_log_setup ("nse-profiler",
#if VERBOSE
"DEBUG",
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index de27cd276..d3637af44 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -952,6 +952,10 @@ main (int argc, char *const *argv)
1, &GNUNET_GETOPT_set_string, &put_uri},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-peerinfo",
gettext_noop ("Print information about peers."),
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index 2ad8468ef..73936a489 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -967,6 +967,9 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_END
};
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-pt",
gettext_noop
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 3eef887fc..add2ddf41 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -240,6 +240,10 @@ main (int argc, char *const *argv)
&GNUNET_GETOPT_set_one, &watch},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-statistics [options [value]]",
gettext_noop
diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c
index 7b1d9dfff..3020a73be 100644
--- a/src/template/gnunet-template.c
+++ b/src/template/gnunet-template.c
@@ -63,6 +63,10 @@ main (int argc, char *const *argv)
/* FIMXE: add options here */
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-template",
gettext_noop ("help text"), options, &run,
diff --git a/src/testing_old/gnunet-testing.c b/src/testing_old/gnunet-testing.c
index bdbb5e8c5..375185b0e 100644
--- a/src/testing_old/gnunet-testing.c
+++ b/src/testing_old/gnunet-testing.c
@@ -282,6 +282,10 @@ main (int argc, char *const *argv)
GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template},
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-testing",
gettext_noop ("Command line tool to access the testing library"), options, &run,
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 57da127fd..356e2c963 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -1356,6 +1356,9 @@ main (int argc, char *const *argv)
};
int ret;
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
ret =
(GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-topology",
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 3b6b7e4c5..d07afccea 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -639,6 +639,10 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-transport",
gettext_noop
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c
index 142dd0d2f..559637748 100644
--- a/src/util/gnunet-resolver.c
+++ b/src/util/gnunet-resolver.c
@@ -149,6 +149,10 @@ main (int argc, char *const *argv)
0, &GNUNET_GETOPT_set_one, &reverse },
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-resolver [hostname]",
gettext_noop ("Use build-in GNUnet stub resolver"),
diff --git a/src/util/gnunet-rsa.c b/src/util/gnunet-rsa.c
index f3cd83a8b..fc9d20064 100644
--- a/src/util/gnunet-rsa.c
+++ b/src/util/gnunet-rsa.c
@@ -119,6 +119,10 @@ main (int argc, char *const *argv)
0, &GNUNET_GETOPT_set_one, &print_short_identity },
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-rsa [OPTIONS] keyfile",
gettext_noop ("Manipulate GNUnet private RSA key files"),
diff --git a/src/util/program.c b/src/util/program.c
index 9e1a83d0b..a8178b93a 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -165,6 +165,7 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName,
char *lpfx;
char *spc;
+
logfile = NULL;
gargs = getenv ("GNUNET_ARGS");
if (gargs != NULL)
diff --git a/src/util/strings.c b/src/util/strings.c
index 11134f139..cc44767d6 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -32,6 +32,7 @@
#include "gnunet_common.h"
#include "gnunet_strings_lib.h"
#include <unicase.h>
+#include <unistr.h>
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -1113,4 +1114,93 @@ GNUNET_STRINGS_to_address_ip (const char *addr,
return GNUNET_STRINGS_to_address_ipv4 (addr, addrlen, (struct sockaddr_in *) r_buf);
}
+/**
+ * Makes a copy of argv that consists of a single memory chunk that can be
+ * freed with a single call to GNUNET_free ();
+ */
+static char *const *
+_make_continuous_arg_copy (int argc, char *const *argv)
+{
+ size_t argvsize = 0;
+ int i;
+ char **new_argv;
+ char *p;
+ for (i = 0; i < argc; i++)
+ argvsize += strlen (argv[i]) + 1 + sizeof (char *);
+ new_argv = GNUNET_malloc (argvsize + sizeof (char *));
+ p = (char *) &new_argv[argc + 1];
+ for (i = 0; i < argc; i++)
+ {
+ new_argv[i] = p;
+ strcpy (p, argv[i]);
+ p += strlen (argv[i]) + 1;
+ }
+ new_argv[argc] = NULL;
+ return (char *const *) new_argv;
+}
+
+/**
+ * Returns utf-8 encoded arguments.
+ * Does nothing (returns a copy of argc and argv) on any platform
+ * other than W32.
+ * Returned argv has u8argv[u8argc] == NULL.
+ * Returned argv is a single memory block, and can be freed with a single
+ * GNUNET_free () call.
+ *
+ * @param argc argc (as given by main())
+ * @param argv argv (as given by main())
+ * @param u8argc a location to store new argc in (though it's th same as argc)
+ * @param u8argv a location to store new argv in
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int
+GNUNET_STRINGS_get_utf8_args (int argc, char *const *argv, int *u8argc, char *const **u8argv)
+{
+#if WINDOWS
+ wchar_t *wcmd;
+ wchar_t **wargv;
+ int wargc;
+ int i;
+ char **split_u8argv;
+
+ wcmd = GetCommandLineW ();
+ if (NULL == wcmd)
+ return GNUNET_SYSERR;
+ wargv = CommandLineToArgvW (wcmd, &wargc);
+ if (NULL == wargv)
+ return GNUNET_SYSERR;
+
+ split_u8argv = GNUNET_malloc (argc * sizeof (char *));
+
+ for (i = 0; i < wargc; i++)
+ {
+ size_t strl;
+ /* Hopefully it will allocate us NUL-terminated strings... */
+ split_u8argv[i] = (char *) u16_to_u8 (wargv[i], wcslen (wargv[i]) + 1, NULL, &strl);
+ if (split_u8argv == NULL)
+ {
+ int j;
+ for (j = 0; j < i; j++)
+ free (split_u8argv[j]);
+ GNUNET_free (split_u8argv);
+ LocalFree (wargv);
+ return GNUNET_SYSERR;
+ }
+ }
+
+ *u8argv = _make_continuous_arg_copy (wargc, split_u8argv);
+ *u8argc = wargc;
+
+ for (i = 0; i < wargc; i++)
+ free (split_u8argv[i]);
+ free (split_u8argv);
+ return GNUNET_OK;
+#else
+ char *const *new_argv = (char *const *) _make_continuous_arg_copy (argc, argv);
+ *u8argv = new_argv;
+ *u8argc = argc;
+ return GNUNET_OK;
+#endif
+}
+
/* end of strings.c */
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c
index ecc0442c6..b75b1d29a 100644
--- a/src/vpn/gnunet-vpn.c
+++ b/src/vpn/gnunet-vpn.c
@@ -323,6 +323,10 @@ main (int argc, char *const *argv)
GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
GNUNET_GETOPT_OPTION_END
};
+
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ return 2;
+
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-vpn",
gettext_noop