diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-17 12:07:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-17 12:07:08 +0100 |
commit | 5b085881ab278a85c3ef3a1d91c58a5724a4e430 (patch) | |
tree | 6da52a32d424e01d68d98216f254612492ed1754 | |
parent | 2951cdb72d730529e2382fca76607681cfc0a3c6 (diff) | |
parent | c253a40bae417335fab8446f3c7182c8c5d4833f (diff) | |
download | gnunet-5b085881ab278a85c3ef3a1d91c58a5724a4e430.tar.gz gnunet-5b085881ab278a85c3ef3a1d91c58a5724a4e430.zip |
Merge branch 'getopt'
66 files changed, 2983 insertions, 1398 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 49886eb56..78c78738a 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -121,12 +121,12 @@ static struct GNUNET_SCHEDULER_Task *timeout_task; | |||
121 | /** | 121 | /** |
122 | * Do we want to give our stdout to gnunet-service-arm? | 122 | * Do we want to give our stdout to gnunet-service-arm? |
123 | */ | 123 | */ |
124 | static unsigned int no_stdout; | 124 | static int no_stdout; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Do we want to give our stderr to gnunet-service-arm? | 127 | * Do we want to give our stderr to gnunet-service-arm? |
128 | */ | 128 | */ |
129 | static unsigned int no_stderr; | 129 | static int no_stderr; |
130 | 130 | ||
131 | /** | 131 | /** |
132 | * Handle for the task running the #action_loop(). | 132 | * Handle for the task running the #action_loop(). |
@@ -762,35 +762,70 @@ run (void *cls, | |||
762 | int | 762 | int |
763 | main (int argc, char *const *argv) | 763 | main (int argc, char *const *argv) |
764 | { | 764 | { |
765 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 765 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
766 | {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), | 766 | |
767 | GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, | 767 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
768 | {'i', "init", "SERVICE", gettext_noop ("start a particular service"), | 768 | "end", |
769 | GNUNET_YES, &GNUNET_GETOPT_set_string, &init}, | 769 | gettext_noop ("stop all GNUnet services"), |
770 | {'k', "kill", "SERVICE", gettext_noop ("stop a particular service"), | 770 | &end), |
771 | GNUNET_YES, &GNUNET_GETOPT_set_string, &term}, | 771 | |
772 | {'s', "start", NULL, gettext_noop ("start all GNUnet default services"), | 772 | GNUNET_GETOPT_OPTION_STRING ('i', |
773 | GNUNET_NO, &GNUNET_GETOPT_set_one, &start}, | 773 | "init", |
774 | {'r', "restart", NULL, | 774 | "SERVICE", |
775 | gettext_noop ("stop and start all GNUnet default services"), | 775 | gettext_noop ("start a particular service"), |
776 | GNUNET_NO, &GNUNET_GETOPT_set_one, &restart}, | 776 | &init), |
777 | {'d', "delete", NULL, | 777 | |
778 | gettext_noop ("delete config file and directory on exit"), | 778 | GNUNET_GETOPT_OPTION_STRING ('k', |
779 | GNUNET_NO, &GNUNET_GETOPT_set_one, &delete}, | 779 | "kill", |
780 | {'m', "monitor", NULL, | 780 | "SERVICE", |
781 | gettext_noop ("monitor ARM activities"), | 781 | gettext_noop ("stop a particular service"), |
782 | GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor}, | 782 | &term), |
783 | {'q', "quiet", NULL, gettext_noop ("don't print status messages"), | 783 | |
784 | GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, | 784 | GNUNET_GETOPT_OPTION_SET_ONE ('s', |
785 | {'T', "timeout", "DELAY", | 785 | "start", |
786 | gettext_noop ("exit with error status if operation does not finish after DELAY"), | 786 | gettext_noop ("start all GNUnet default services"), |
787 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout}, | 787 | &start), |
788 | {'I', "info", NULL, gettext_noop ("list currently running services"), | 788 | |
789 | GNUNET_NO, &GNUNET_GETOPT_set_one, &list}, | 789 | GNUNET_GETOPT_OPTION_SET_ONE ('r', |
790 | {'O', "no-stdout", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard output"), | 790 | "restart", |
791 | GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stdout}, | 791 | gettext_noop ("stop and start all GNUnet default services"), |
792 | {'E', "no-stderr", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard error"), | 792 | &restart), |
793 | GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stderr}, | 793 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
794 | "delete", | ||
795 | gettext_noop ("delete config file and directory on exit"), | ||
796 | &delete), | ||
797 | |||
798 | GNUNET_GETOPT_OPTION_SET_ONE ('m', | ||
799 | "monitor", | ||
800 | gettext_noop ("monitor ARM activities"), | ||
801 | &monitor), | ||
802 | |||
803 | GNUNET_GETOPT_OPTION_SET_ONE ('q', | ||
804 | "quiet", | ||
805 | gettext_noop ("don't print status messages"), | ||
806 | &quiet), | ||
807 | |||
808 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T', | ||
809 | "timeout", | ||
810 | "DELAY", | ||
811 | gettext_noop ("exit with error status if operation does not finish after DELAY"), | ||
812 | &timeout), | ||
813 | |||
814 | GNUNET_GETOPT_OPTION_SET_ONE ('I', | ||
815 | "info", | ||
816 | gettext_noop ("list currently running services"), | ||
817 | &list), | ||
818 | |||
819 | GNUNET_GETOPT_OPTION_SET_ONE ('O', | ||
820 | "no-stdout", | ||
821 | gettext_noop ("don't let gnunet-service-arm inherit standard output"), | ||
822 | &no_stdout), | ||
823 | |||
824 | GNUNET_GETOPT_OPTION_SET_ONE ('E', | ||
825 | "no-stderr", | ||
826 | gettext_noop ("don't let gnunet-service-arm inherit standard error"), | ||
827 | &no_stderr), | ||
828 | |||
794 | GNUNET_GETOPT_OPTION_END | 829 | GNUNET_GETOPT_OPTION_END |
795 | }; | 830 | }; |
796 | 831 | ||
diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c index c19afe895..1bb7fdee7 100644 --- a/src/ats-tests/gnunet-solver-eval.c +++ b/src/ats-tests/gnunet-solver-eval.c | |||
@@ -931,17 +931,24 @@ main (int argc, char *argv[]) | |||
931 | opt_log = GNUNET_NO; | 931 | opt_log = GNUNET_NO; |
932 | opt_plot = GNUNET_NO; | 932 | opt_plot = GNUNET_NO; |
933 | 933 | ||
934 | static struct GNUNET_GETOPT_CommandLineOption options[] = | 934 | struct GNUNET_GETOPT_CommandLineOption options[] = |
935 | { | 935 | { |
936 | { 's', "solver", NULL, | 936 | GNUNET_GETOPT_OPTION_STRING ('s', |
937 | gettext_noop ("solver to use"), | 937 | "solver", |
938 | 1, &GNUNET_GETOPT_set_string, &opt_solver}, | 938 | NULL, |
939 | { 'e', "experiment", NULL, | 939 | gettext_noop ("solver to use"), |
940 | gettext_noop ("experiment to use"), | 940 | &opt_solver), |
941 | 1, &GNUNET_GETOPT_set_string, &opt_exp_file}, | 941 | |
942 | { 'e', "experiment", NULL, | 942 | GNUNET_GETOPT_OPTION_STRING ('e', |
943 | gettext_noop ("experiment to use"), | 943 | "experiment", |
944 | 1, &GNUNET_GETOPT_set_one, &opt_verbose}, | 944 | NULL, |
945 | gettext_noop ("experiment to use"), | ||
946 | &opt_exp_file), | ||
947 | |||
948 | GNUNET_GETOPT_OPTION_SET_ONE ('e', | ||
949 | "experiment", | ||
950 | gettext_noop ("experiment to use"), | ||
951 | &opt_verbose), | ||
945 | GNUNET_GETOPT_OPTION_END | 952 | GNUNET_GETOPT_OPTION_END |
946 | }; | 953 | }; |
947 | 954 | ||
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 5fc1d6e92..f645ba56d 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -944,34 +944,62 @@ main (int argc, | |||
944 | stat_receive_done = GNUNET_NO; | 944 | stat_receive_done = GNUNET_NO; |
945 | opt_type_str = NULL; | 945 | opt_type_str = NULL; |
946 | 946 | ||
947 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 947 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
948 | { 'u', "used", NULL, | 948 | GNUNET_GETOPT_OPTION_SET_ONE ('u', |
949 | gettext_noop ("get list of active addresses currently used"), 0, | 949 | "used", |
950 | &GNUNET_GETOPT_set_one, &opt_list_used }, | 950 | gettext_noop ("get list of active addresses currently used"), |
951 | { 'a', "all", NULL, gettext_noop ("get list of all active addresses"), 0, | 951 | &opt_list_used), |
952 | &GNUNET_GETOPT_set_one, &opt_list_all }, | 952 | GNUNET_GETOPT_OPTION_SET_ONE ('a', |
953 | { 'C', "connect", "PEER", | 953 | "all", |
954 | gettext_noop ("connect to PEER"), 1, | 954 | gettext_noop ("get list of all active addresses"), |
955 | &GNUNET_GETOPT_set_string, &cpid_str }, | 955 | &opt_list_all), |
956 | { 'n', "numeric", NULL, | 956 | |
957 | gettext_noop ("do not resolve IP addresses to hostnames"), 0, | 957 | GNUNET_GETOPT_OPTION_STRING ('C', |
958 | &GNUNET_GETOPT_set_one, &opt_resolve_addresses_numeric }, | 958 | "connect", |
959 | { 'm', "monitor", NULL, gettext_noop ("monitor mode"), 0, | 959 | NULL, |
960 | &GNUNET_GETOPT_set_one, &opt_monitor }, | 960 | gettext_noop ("connect to PEER"), |
961 | { 'p', "preference", NULL, gettext_noop ("set preference for the given peer"), | 961 | &cpid_str), |
962 | 0, &GNUNET_GETOPT_set_one, &opt_set_pref }, | 962 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
963 | { 'q', "quotas", NULL, gettext_noop ("print all configured quotas"), 0, | 963 | "numeric", |
964 | &GNUNET_GETOPT_set_one, &opt_print_quotas }, | 964 | gettext_noop ("do not resolve IP addresses to hostnames"), |
965 | { 'i', "id", "TYPE", gettext_noop ("peer id"), 1, &GNUNET_GETOPT_set_string, | 965 | &opt_resolve_addresses_numeric), |
966 | &opt_pid_str }, | 966 | |
967 | { 't', "type", "TYPE", | 967 | GNUNET_GETOPT_OPTION_SET_ONE ('m', |
968 | gettext_noop ("preference type to set: latency | bandwidth"), 1, | 968 | "monitor", |
969 | &GNUNET_GETOPT_set_string, &opt_type_str }, | 969 | gettext_noop ("monitor mode"), |
970 | { 'k', "value", "VALUE", gettext_noop ("preference value"), 1, | 970 | &opt_monitor), |
971 | &GNUNET_GETOPT_set_uint, &opt_pref_value }, | 971 | |
972 | { 'V', "verbose", NULL, | 972 | GNUNET_GETOPT_OPTION_SET_ONE ('p', |
973 | gettext_noop ("verbose output (include ATS address properties)"), 0, | 973 | "preference", |
974 | &GNUNET_GETOPT_set_one, &opt_verbose }, | 974 | gettext_noop ("set preference for the given peer"), |
975 | &opt_set_pref), | ||
976 | |||
977 | GNUNET_GETOPT_OPTION_SET_ONE ('q', | ||
978 | "quotas", | ||
979 | gettext_noop ("print all configured quotas"), | ||
980 | &opt_print_quotas), | ||
981 | GNUNET_GETOPT_OPTION_STRING ('i', | ||
982 | "id", | ||
983 | "TYPE", | ||
984 | gettext_noop ("peer id"), | ||
985 | &opt_pid_str), | ||
986 | |||
987 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
988 | "type", | ||
989 | "TYPE", | ||
990 | gettext_noop ("preference type to set: latency | bandwidth"), | ||
991 | &opt_type_str), | ||
992 | |||
993 | GNUNET_GETOPT_OPTION_SET_UINT ('k', | ||
994 | "value", | ||
995 | "VALUE", | ||
996 | gettext_noop ("preference value"), | ||
997 | &opt_pref_value), | ||
998 | |||
999 | GNUNET_GETOPT_OPTION_SET_ONE ('V', | ||
1000 | "verbose", | ||
1001 | gettext_noop ("verbose output (include ATS address properties)"), | ||
1002 | &opt_verbose), | ||
975 | GNUNET_GETOPT_OPTION_END | 1003 | GNUNET_GETOPT_OPTION_END |
976 | }; | 1004 | }; |
977 | 1005 | ||
diff --git a/src/auction/gnunet-auction-create.c b/src/auction/gnunet-auction-create.c index a4c029572..e6fcab097 100644 --- a/src/auction/gnunet-auction-create.c +++ b/src/auction/gnunet-auction-create.c | |||
@@ -155,30 +155,49 @@ fail: | |||
155 | int | 155 | int |
156 | main (int argc, char *const *argv) | 156 | main (int argc, char *const *argv) |
157 | { | 157 | { |
158 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 158 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
159 | {'d', "description", "FILE", | 159 | |
160 | gettext_noop ("description of the item to be sold"), | 160 | GNUNET_GETOPT_OPTION_FILENAME ('d', |
161 | 1, &GNUNET_GETOPT_set_filename, &fndesc}, | 161 | "description", |
162 | {'p', "pricemap", "FILE", | 162 | "FILE", |
163 | gettext_noop ("mapping of possible prices"), | 163 | gettext_noop ("description of the item to be sold"), |
164 | 1, &GNUNET_GETOPT_set_filename, &fnprices}, | 164 | &fndesc), |
165 | {'r', "roundtime", "DURATION", | 165 | |
166 | gettext_noop ("max duration per round"), | 166 | GNUNET_GETOPT_OPTION_FILENAME ('p', |
167 | 1, &GNUNET_GETOPT_set_relative_time, &dround}, | 167 | "pricemap", |
168 | {'s', "regtime", "DURATION", | 168 | "FILE", |
169 | gettext_noop ("duration until auction starts"), | 169 | gettext_noop ("mapping of possible prices"), |
170 | 1, &GNUNET_GETOPT_set_relative_time, &dstart}, | 170 | &fnprices), |
171 | {'m', "m", "NUMBER", | 171 | |
172 | gettext_noop ("number of items to sell\n" | 172 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('r', |
173 | "0 for first price auction\n" | 173 | "roundtime", |
174 | ">0 for vickrey/M+1st price auction"), | 174 | "DURATION", |
175 | 1, &GNUNET_GETOPT_set_uint, &m}, | 175 | gettext_noop ("max duration per round"), |
176 | {'u', "public", NULL, | 176 | &dround), |
177 | gettext_noop ("public auction outcome"), | 177 | |
178 | 0, &GNUNET_GETOPT_set_one, &outcome}, | 178 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('s', |
179 | {'i', "interactive", NULL, | 179 | "regtime", |
180 | gettext_noop ("keep running in foreground until auction completes"), | 180 | "DURATION", |
181 | 0, &GNUNET_GETOPT_set_one, &interactive}, | 181 | gettext_noop ("duration until auction starts"), |
182 | &dstart), | ||
183 | GNUNET_GETOPT_OPTION_SET_UINT ('m', | ||
184 | "m", | ||
185 | "NUMBER", | ||
186 | gettext_noop ("number of items to sell\n" | ||
187 | "0 for first price auction\n" | ||
188 | ">0 for vickrey/M+1st price auction"), | ||
189 | &m), | ||
190 | |||
191 | GNUNET_GETOPT_OPTION_SET_ONE ('u', | ||
192 | "public", | ||
193 | gettext_noop ("public auction outcome"), | ||
194 | &outcome), | ||
195 | |||
196 | GNUNET_GETOPT_OPTION_SET_ONE ('i', | ||
197 | "interactive", | ||
198 | gettext_noop ("keep running in foreground until auction completes"), | ||
199 | &interactive), | ||
200 | |||
182 | GNUNET_GETOPT_OPTION_END | 201 | GNUNET_GETOPT_OPTION_END |
183 | }; | 202 | }; |
184 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 203 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index 1556f7d86..57eeac735 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -920,32 +920,54 @@ main (int argc, | |||
920 | { | 920 | { |
921 | int res; | 921 | int res; |
922 | const char helpstr[] = "Create tunnels and retrieve info about CADET's status."; | 922 | const char helpstr[] = "Create tunnels and retrieve info about CADET's status."; |
923 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 923 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
924 | /* I would use the terminology 'circuit' here... --lynX */ | 924 | /* I would use the terminology 'circuit' here... --lynX */ |
925 | {'C', "connection", "CONNECTION_ID", | 925 | GNUNET_GETOPT_OPTION_STRING ('C', |
926 | gettext_noop ("Provide information about a particular connection"), | 926 | "connection", |
927 | GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id}, | 927 | "CONNECTION_ID", |
928 | {'e', "echo", NULL, | 928 | gettext_noop ("Provide information about a particular connection"), |
929 | gettext_noop ("Activate echo mode"), | 929 | &conn_id), |
930 | GNUNET_NO, &GNUNET_GETOPT_set_one, &echo}, | 930 | |
931 | {'d', "dump", NULL, | 931 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
932 | gettext_noop ("Dump debug information to STDERR"), | 932 | "echo", |
933 | GNUNET_NO, &GNUNET_GETOPT_set_one, &dump}, | 933 | gettext_noop ("Activate echo mode"), |
934 | {'o', "open-port", "SHARED_SECRET", | 934 | &echo), |
935 | gettext_noop ("Listen for connections using a shared secret among sender and recipient"), | 935 | |
936 | GNUNET_YES, &GNUNET_GETOPT_set_string, &listen_port}, | 936 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
937 | {'p', "peer", "PEER_ID", | 937 | "dump", |
938 | gettext_noop ("Provide information about a patricular peer"), | 938 | gettext_noop ("Dump debug information to STDERR"), |
939 | GNUNET_YES, &GNUNET_GETOPT_set_string, &peer_id}, | 939 | &dump), |
940 | {'P', "peers", NULL, | 940 | |
941 | gettext_noop ("Provide information about all peers"), | 941 | GNUNET_GETOPT_OPTION_STRING ('o', |
942 | GNUNET_NO, &GNUNET_GETOPT_set_one, &request_peers}, | 942 | "open-port", |
943 | {'t', "tunnel", "TUNNEL_ID", | 943 | "SHARED_SECRET", |
944 | gettext_noop ("Provide information about a particular tunnel"), | 944 | gettext_noop ("Listen for connections using a shared secret among sender and recipient"), |
945 | GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id}, | 945 | &listen_port), |
946 | {'T', "tunnels", NULL, | 946 | |
947 | gettext_noop ("Provide information about all tunnels"), | 947 | |
948 | GNUNET_NO, &GNUNET_GETOPT_set_one, &request_tunnels}, | 948 | GNUNET_GETOPT_OPTION_STRING ('p', |
949 | "peer", | ||
950 | "PEER_ID", | ||
951 | gettext_noop ("Provide information about a patricular peer"), | ||
952 | &peer_id), | ||
953 | |||
954 | |||
955 | GNUNET_GETOPT_OPTION_SET_ONE ('P', | ||
956 | "peers", | ||
957 | gettext_noop ("Provide information about all peers"), | ||
958 | &request_peers), | ||
959 | |||
960 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
961 | "tunnel", | ||
962 | "TUNNEL_ID", | ||
963 | gettext_noop ("Provide information about a particular tunnel"), | ||
964 | &tunnel_id), | ||
965 | |||
966 | |||
967 | GNUNET_GETOPT_OPTION_SET_ONE ('T', | ||
968 | "tunnels", | ||
969 | gettext_noop ("Provide information about all tunnels"), | ||
970 | &request_tunnels), | ||
949 | 971 | ||
950 | GNUNET_GETOPT_OPTION_END | 972 | GNUNET_GETOPT_OPTION_END |
951 | }; | 973 | }; |
diff --git a/src/consensus/gnunet-consensus-profiler.c b/src/consensus/gnunet-consensus-profiler.c index 65542f4cd..8cc1b3512 100644 --- a/src/consensus/gnunet-consensus-profiler.c +++ b/src/consensus/gnunet-consensus-profiler.c | |||
@@ -515,31 +515,55 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
515 | int | 515 | int |
516 | main (int argc, char **argv) | 516 | main (int argc, char **argv) |
517 | { | 517 | { |
518 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 518 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
519 | { 'n', "num-peers", NULL, | 519 | |
520 | gettext_noop ("number of peers in consensus"), | 520 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
521 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, | 521 | "num-peers", |
522 | { 'k', "value-replication", NULL, | 522 | NULL, |
523 | gettext_noop ("how many peers (random selection without replacement) receive one value?"), | 523 | gettext_noop ("number of peers in consensus"), |
524 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &replication }, | 524 | &num_peers), |
525 | { 'x', "num-values", NULL, | 525 | |
526 | gettext_noop ("number of values"), | 526 | GNUNET_GETOPT_OPTION_SET_UINT ('k', |
527 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_values }, | 527 | "value-replication", |
528 | { 't', "timeout", NULL, | 528 | NULL, |
529 | gettext_noop ("consensus timeout"), | 529 | gettext_noop ("how many peers (random selection without replacement) receive one value?"), |
530 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &conclude_timeout }, | 530 | &replication), |
531 | { 'd', "delay", NULL, | 531 | |
532 | gettext_noop ("delay until consensus starts"), | 532 | GNUNET_GETOPT_OPTION_SET_UINT ('x', |
533 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay }, | 533 | "num-values", |
534 | { 's', "statistics", NULL, | 534 | NULL, |
535 | gettext_noop ("write statistics to file"), | 535 | gettext_noop ("number of values"), |
536 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, | 536 | &num_values), |
537 | { 'S', "dist-static", NULL, | 537 | |
538 | gettext_noop ("distribute elements to a static subset of good peers"), | 538 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', |
539 | GNUNET_YES, &GNUNET_GETOPT_set_one, &dist_static }, | 539 | "timeout", |
540 | { 'V', "verbose", NULL, | 540 | NULL, |
541 | gettext_noop ("be more verbose (print received values)"), | 541 | gettext_noop ("consensus timeout"), |
542 | GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, | 542 | &conclude_timeout), |
543 | |||
544 | |||
545 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('d', | ||
546 | "delay", | ||
547 | NULL, | ||
548 | gettext_noop ("delay until consensus starts"), | ||
549 | &consensus_delay), | ||
550 | |||
551 | GNUNET_GETOPT_OPTION_FILENAME ('s', | ||
552 | "statistics", | ||
553 | "FILENAME", | ||
554 | gettext_noop ("write statistics to file"), | ||
555 | &statistics_filename), | ||
556 | |||
557 | GNUNET_GETOPT_OPTION_SET_ONE ('S', | ||
558 | "dist-static", | ||
559 | gettext_noop ("distribute elements to a static subset of good peers"), | ||
560 | &dist_static), | ||
561 | |||
562 | GNUNET_GETOPT_OPTION_SET_ONE ('V', | ||
563 | "verbose", | ||
564 | gettext_noop ("be more verbose (print received values)"), | ||
565 | &verbose), | ||
566 | |||
543 | GNUNET_GETOPT_OPTION_END | 567 | GNUNET_GETOPT_OPTION_END |
544 | }; | 568 | }; |
545 | conclude_timeout = GNUNET_TIME_UNIT_SECONDS; | 569 | conclude_timeout = GNUNET_TIME_UNIT_SECONDS; |
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c index d91dc304d..ed89b1946 100644 --- a/src/core/gnunet-core.c +++ b/src/core/gnunet-core.c | |||
@@ -171,10 +171,11 @@ main (int argc, | |||
171 | char *const *argv) | 171 | char *const *argv) |
172 | { | 172 | { |
173 | int res; | 173 | int res; |
174 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 174 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
175 | {'m', "monitor", NULL, | 175 | GNUNET_GETOPT_OPTION_SET_ONE ('m', |
176 | gettext_noop ("provide information about all current connections (continuously)"), | 176 | "monitor", |
177 | 0, &GNUNET_GETOPT_set_one, &monitor_connections}, | 177 | gettext_noop ("provide information about all current connections (continuously)"), |
178 | &monitor_connections), | ||
178 | GNUNET_GETOPT_OPTION_END | 179 | GNUNET_GETOPT_OPTION_END |
179 | }; | 180 | }; |
180 | 181 | ||
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c index b3d14c43c..509c7f8b1 100644 --- a/src/datastore/gnunet-datastore.c +++ b/src/datastore/gnunet-datastore.c | |||
@@ -239,10 +239,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
239 | int | 239 | int |
240 | main (int argc, char *const *argv) | 240 | main (int argc, char *const *argv) |
241 | { | 241 | { |
242 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 242 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
243 | { 's', "sourcecfg", "FILENAME", | 243 | GNUNET_GETOPT_OPTION_FILENAME ('s', |
244 | gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"), | 244 | "sourcecfg", |
245 | 1, &GNUNET_GETOPT_set_filename, &alternative_cfg }, | 245 | "FILENAME", |
246 | gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"), | ||
247 | &alternative_cfg), | ||
246 | GNUNET_GETOPT_OPTION_END | 248 | GNUNET_GETOPT_OPTION_END |
247 | }; | 249 | }; |
248 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 250 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index ce479dc3e..67f0ce76d 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -50,7 +50,7 @@ static struct GNUNET_TIME_Relative timeout_request = { 60000 }; | |||
50 | /** | 50 | /** |
51 | * Be verbose | 51 | * Be verbose |
52 | */ | 52 | */ |
53 | static int verbose; | 53 | static unsigned int verbose; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Use DHT demultixplex_everywhere | 56 | * Use DHT demultixplex_everywhere |
@@ -226,33 +226,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
226 | 226 | ||
227 | } | 227 | } |
228 | 228 | ||
229 | |||
230 | /** | ||
231 | * gnunet-dht-get command line options | ||
232 | */ | ||
233 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
234 | {'k', "key", "KEY", | ||
235 | gettext_noop ("the query key"), | ||
236 | 1, &GNUNET_GETOPT_set_string, &query_key}, | ||
237 | {'r', "replication", "LEVEL", | ||
238 | gettext_noop ("how many parallel requests (replicas) to create"), | ||
239 | 1, &GNUNET_GETOPT_set_uint, &replication}, | ||
240 | {'t', "type", "TYPE", | ||
241 | gettext_noop ("the type of data to look for"), | ||
242 | 1, &GNUNET_GETOPT_set_uint, &query_type}, | ||
243 | {'T', "timeout", "TIMEOUT", | ||
244 | gettext_noop ("how long to execute this query before giving up?"), | ||
245 | 1, &GNUNET_GETOPT_set_relative_time, &timeout_request}, | ||
246 | {'x', "demultiplex", NULL, | ||
247 | gettext_noop ("use DHT's demultiplex everywhere option"), | ||
248 | 0, &GNUNET_GETOPT_set_one, &demultixplex_everywhere}, | ||
249 | {'V', "verbose", NULL, | ||
250 | gettext_noop ("be verbose (print progress information)"), | ||
251 | 0, &GNUNET_GETOPT_set_one, &verbose}, | ||
252 | GNUNET_GETOPT_OPTION_END | ||
253 | }; | ||
254 | |||
255 | |||
256 | /** | 229 | /** |
257 | * Entry point for gnunet-dht-get | 230 | * Entry point for gnunet-dht-get |
258 | * | 231 | * |
@@ -263,6 +236,45 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
263 | int | 236 | int |
264 | main (int argc, char *const *argv) | 237 | main (int argc, char *const *argv) |
265 | { | 238 | { |
239 | |||
240 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
241 | |||
242 | GNUNET_GETOPT_OPTION_STRING ('k', | ||
243 | "key", | ||
244 | "KEY", | ||
245 | gettext_noop ("the query key"), | ||
246 | &query_key), | ||
247 | |||
248 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
249 | "replication", | ||
250 | "LEVEL", | ||
251 | gettext_noop ("how many parallel requests (replicas) to create"), | ||
252 | &replication), | ||
253 | |||
254 | |||
255 | GNUNET_GETOPT_OPTION_SET_UINT ('t', | ||
256 | "type", | ||
257 | "TYPE", | ||
258 | gettext_noop ("the type of data to look for"), | ||
259 | &query_type), | ||
260 | |||
261 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T', | ||
262 | "timeout", | ||
263 | "TIMEOUT", | ||
264 | gettext_noop ("how long to execute this query before giving up?"), | ||
265 | &timeout_request), | ||
266 | |||
267 | GNUNET_GETOPT_OPTION_SET_ONE ('x', | ||
268 | "demultiplex", | ||
269 | gettext_noop ("use DHT's demultiplex everywhere option"), | ||
270 | &demultixplex_everywhere), | ||
271 | |||
272 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
273 | GNUNET_GETOPT_OPTION_END | ||
274 | }; | ||
275 | |||
276 | |||
277 | |||
266 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 278 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
267 | return 2; | 279 | return 2; |
268 | return (GNUNET_OK == | 280 | return (GNUNET_OK == |
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c index 7f14255d3..e4e8c46a1 100644 --- a/src/dht/gnunet-dht-monitor.c +++ b/src/dht/gnunet-dht-monitor.c | |||
@@ -280,27 +280,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
280 | NULL); | 280 | NULL); |
281 | } | 281 | } |
282 | 282 | ||
283 | |||
284 | /** | ||
285 | * gnunet-dht-monitor command line options | ||
286 | */ | ||
287 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
288 | {'k', "key", "KEY", | ||
289 | gettext_noop ("the query key"), | ||
290 | 1, &GNUNET_GETOPT_set_string, &query_key}, | ||
291 | {'t', "type", "TYPE", | ||
292 | gettext_noop ("the type of data to look for"), | ||
293 | 1, &GNUNET_GETOPT_set_uint, &block_type}, | ||
294 | {'T', "timeout", "TIMEOUT", | ||
295 | gettext_noop ("how long should the monitor command run"), | ||
296 | 1, &GNUNET_GETOPT_set_relative_time, &timeout_request}, | ||
297 | {'V', "verbose", NULL, | ||
298 | gettext_noop ("be verbose (print progress information)"), | ||
299 | 0, &GNUNET_GETOPT_set_one, &verbose}, | ||
300 | GNUNET_GETOPT_OPTION_END | ||
301 | }; | ||
302 | |||
303 | |||
304 | /** | 283 | /** |
305 | * Entry point for gnunet-dht-monitor | 284 | * Entry point for gnunet-dht-monitor |
306 | * | 285 | * |
@@ -311,6 +290,35 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
311 | int | 290 | int |
312 | main (int argc, char *const *argv) | 291 | main (int argc, char *const *argv) |
313 | { | 292 | { |
293 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
294 | |||
295 | GNUNET_GETOPT_OPTION_STRING ('k', | ||
296 | "key", | ||
297 | "KEY", | ||
298 | gettext_noop ("the query key"), | ||
299 | &query_key), | ||
300 | |||
301 | GNUNET_GETOPT_OPTION_SET_UINT ('t', | ||
302 | "type", | ||
303 | "TYPE", | ||
304 | gettext_noop ("the type of data to look for"), | ||
305 | &block_type), | ||
306 | |||
307 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T', | ||
308 | "timeout", | ||
309 | "TIMEOUT", | ||
310 | gettext_noop ("how long should the monitor command run"), | ||
311 | &timeout_request), | ||
312 | |||
313 | GNUNET_GETOPT_OPTION_SET_ONE ('V', | ||
314 | "verbose", | ||
315 | gettext_noop ("be verbose (print progress information)"), | ||
316 | &verbose), | ||
317 | |||
318 | GNUNET_GETOPT_OPTION_END | ||
319 | }; | ||
320 | |||
321 | |||
314 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 322 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
315 | return 2; | 323 | return 2; |
316 | 324 | ||
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index a44e49d70..bf88e5ded 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -54,7 +54,7 @@ static unsigned int replication = 5; | |||
54 | /** | 54 | /** |
55 | * Be verbose | 55 | * Be verbose |
56 | */ | 56 | */ |
57 | static int verbose; | 57 | static unsigned int verbose; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Use #GNUNET_DHT_DEMULTIPLEX_EVERYWHERE. | 60 | * Use #GNUNET_DHT_DEMULTIPLEX_EVERYWHERE. |
@@ -191,39 +191,6 @@ run (void *cls, | |||
191 | NULL); | 191 | NULL); |
192 | } | 192 | } |
193 | 193 | ||
194 | |||
195 | /** | ||
196 | * gnunet-dht-put command line options | ||
197 | */ | ||
198 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
199 | {'d', "data", "DATA", | ||
200 | gettext_noop ("the data to insert under the key"), | ||
201 | 1, &GNUNET_GETOPT_set_string, &data}, | ||
202 | {'e', "expiration", "EXPIRATION", | ||
203 | gettext_noop ("how long to store this entry in the dht (in seconds)"), | ||
204 | 1, &GNUNET_GETOPT_set_relative_time, &expiration}, | ||
205 | {'k', "key", "KEY", | ||
206 | gettext_noop ("the query key"), | ||
207 | 1, &GNUNET_GETOPT_set_string, &query_key}, | ||
208 | {'x', "demultiplex", NULL, | ||
209 | gettext_noop ("use DHT's demultiplex everywhere option"), | ||
210 | 0, &GNUNET_GETOPT_set_one, &demultixplex_everywhere}, | ||
211 | {'r', "replication", "LEVEL", | ||
212 | gettext_noop ("how many replicas to create"), | ||
213 | 1, &GNUNET_GETOPT_set_uint, &replication}, | ||
214 | {'R', "record", NULL, | ||
215 | gettext_noop ("use DHT's record route option"), | ||
216 | 0, &GNUNET_GETOPT_set_one, &record_route}, | ||
217 | {'t', "type", "TYPE", | ||
218 | gettext_noop ("the type to insert data as"), | ||
219 | 1, &GNUNET_GETOPT_set_uint, &query_type}, | ||
220 | {'V', "verbose", NULL, | ||
221 | gettext_noop ("be verbose (print progress information)"), | ||
222 | 0, &GNUNET_GETOPT_set_one, &verbose}, | ||
223 | GNUNET_GETOPT_OPTION_END | ||
224 | }; | ||
225 | |||
226 | |||
227 | /** | 194 | /** |
228 | * Entry point for gnunet-dht-put | 195 | * Entry point for gnunet-dht-put |
229 | * | 196 | * |
@@ -234,6 +201,55 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
234 | int | 201 | int |
235 | main (int argc, char *const *argv) | 202 | main (int argc, char *const *argv) |
236 | { | 203 | { |
204 | |||
205 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
206 | |||
207 | GNUNET_GETOPT_OPTION_STRING ('d', | ||
208 | "data", | ||
209 | "DATA", | ||
210 | gettext_noop ("the data to insert under the key"), | ||
211 | &data), | ||
212 | |||
213 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('e', | ||
214 | "expiration", | ||
215 | "EXPIRATION", | ||
216 | gettext_noop ("how long to store this entry in the dht (in seconds)"), | ||
217 | &expiration), | ||
218 | |||
219 | GNUNET_GETOPT_OPTION_STRING ('k', | ||
220 | "key", | ||
221 | "KEY", | ||
222 | gettext_noop ("the query key"), | ||
223 | &query_key), | ||
224 | |||
225 | GNUNET_GETOPT_OPTION_SET_ONE ('x', | ||
226 | "demultiplex", | ||
227 | gettext_noop ("use DHT's demultiplex everywhere option"), | ||
228 | &demultixplex_everywhere), | ||
229 | |||
230 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
231 | "replication", | ||
232 | "LEVEL", | ||
233 | gettext_noop ("how many replicas to create"), | ||
234 | &replication), | ||
235 | |||
236 | GNUNET_GETOPT_OPTION_SET_ONE ('R', | ||
237 | "record", | ||
238 | gettext_noop ("use DHT's record route option"), | ||
239 | &record_route), | ||
240 | |||
241 | GNUNET_GETOPT_OPTION_SET_UINT ('t', | ||
242 | "type", | ||
243 | "TYPE", | ||
244 | gettext_noop ("the type to insert data as"), | ||
245 | &query_type), | ||
246 | |||
247 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
248 | |||
249 | GNUNET_GETOPT_OPTION_END | ||
250 | }; | ||
251 | |||
252 | |||
237 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, | 253 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, |
238 | &argc, &argv)) | 254 | &argc, &argv)) |
239 | return 2; | 255 | return 2; |
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 460eaa572..f65141640 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -1181,31 +1181,54 @@ main (int argc, char *const *argv) | |||
1181 | { | 1181 | { |
1182 | int rc; | 1182 | int rc; |
1183 | 1183 | ||
1184 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 1184 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1185 | {'n', "peers", "COUNT", | 1185 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
1186 | gettext_noop ("number of peers to start"), | 1186 | "peers", |
1187 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | 1187 | "COUNT", |
1188 | {'s', "searches", "COUNT", | 1188 | gettext_noop ("number of peers to start"), |
1189 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), | 1189 | &num_peers), |
1190 | 1, &GNUNET_GETOPT_set_uint, &max_searches}, | 1190 | |
1191 | {'H', "hosts", "FILENAME", | 1191 | GNUNET_GETOPT_OPTION_SET_UINT ('s', |
1192 | gettext_noop ("name of the file with the login information for the testbed"), | 1192 | "searches", |
1193 | 1, &GNUNET_GETOPT_set_string, &hosts_file}, | 1193 | "COUNT", |
1194 | {'D', "delay", "DELAY", | 1194 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), |
1195 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), | 1195 | &max_searches), |
1196 | 1, &GNUNET_GETOPT_set_relative_time, &delay_stats}, | 1196 | |
1197 | {'P', "PUT-delay", "DELAY", | 1197 | GNUNET_GETOPT_OPTION_STRING ('H', |
1198 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), | 1198 | "hosts", |
1199 | 1, &GNUNET_GETOPT_set_relative_time, &delay_put}, | 1199 | "FILENAME", |
1200 | {'G', "GET-delay", "DELAY", | 1200 | gettext_noop ("name of the file with the login information for the testbed"), |
1201 | gettext_noop ("delay to start doing GETs (default: 5 min)"), | 1201 | &hosts_file), |
1202 | 1, &GNUNET_GETOPT_set_relative_time, &delay_get}, | 1202 | |
1203 | {'r', "replication", "DEGREE", | 1203 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('D', |
1204 | gettext_noop ("replication degree for DHT PUTs"), | 1204 | "delay", |
1205 | 1, &GNUNET_GETOPT_set_uint, &replication}, | 1205 | "DELAY", |
1206 | {'t', "timeout", "TIMEOUT", | 1206 | gettext_noop ("delay between rounds for collecting statistics (default: 30 sec)"), |
1207 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), | 1207 | &delay_stats), |
1208 | 1, &GNUNET_GETOPT_set_relative_time, &timeout}, | 1208 | |
1209 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('P', | ||
1210 | "PUT-delay", | ||
1211 | "DELAY", | ||
1212 | gettext_noop ("delay to start doing PUTs (default: 1 sec)"), | ||
1213 | &delay_put), | ||
1214 | |||
1215 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('G', | ||
1216 | "GET-delay", | ||
1217 | "DELAY", | ||
1218 | gettext_noop ("delay to start doing GETs (default: 5 min)"), | ||
1219 | &delay_get), | ||
1220 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
1221 | "replication", | ||
1222 | "DEGREE", | ||
1223 | gettext_noop ("replication degree for DHT PUTs"), | ||
1224 | &replication), | ||
1225 | |||
1226 | |||
1227 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
1228 | "timeout", | ||
1229 | "TIMEOUT", | ||
1230 | gettext_noop ("timeout for DHT PUT and GET requests (default: 1 min)"), | ||
1231 | &timeout), | ||
1209 | GNUNET_GETOPT_OPTION_END | 1232 | GNUNET_GETOPT_OPTION_END |
1210 | }; | 1233 | }; |
1211 | 1234 | ||
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c index 5e6f90555..2436931fb 100644 --- a/src/dns/gnunet-dns-monitor.c +++ b/src/dns/gnunet-dns-monitor.c | |||
@@ -52,7 +52,7 @@ static int ret; | |||
52 | /** | 52 | /** |
53 | * Selected level of verbosity. | 53 | * Selected level of verbosity. |
54 | */ | 54 | */ |
55 | static int verbosity; | 55 | static unsigned int verbosity; |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -346,13 +346,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
346 | int | 346 | int |
347 | main (int argc, char *const *argv) | 347 | main (int argc, char *const *argv) |
348 | { | 348 | { |
349 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 349 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
350 | {'i', "inbound-only", NULL, | 350 | |
351 | gettext_noop ("only monitor DNS queries"), | 351 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
352 | 0, &GNUNET_GETOPT_set_one, &inbound_only}, | 352 | "inbound-only", |
353 | {'o', "outbound-only", NULL, | 353 | gettext_noop ("only monitor DNS queries"), |
354 | gettext_noop ("only monitor DNS replies"), | 354 | &inbound_only), |
355 | 0, &GNUNET_GETOPT_set_one, &outbound_only}, | 355 | |
356 | GNUNET_GETOPT_OPTION_SET_ONE ('o', | ||
357 | "outbound-only", | ||
358 | gettext_noop ("only monitor DNS queries"), | ||
359 | &outbound_only), | ||
360 | |||
356 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 361 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
357 | GNUNET_GETOPT_OPTION_END | 362 | GNUNET_GETOPT_OPTION_END |
358 | }; | 363 | }; |
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c index 89929815a..0469af732 100644 --- a/src/dns/gnunet-dns-redirector.c +++ b/src/dns/gnunet-dns-redirector.c | |||
@@ -52,7 +52,7 @@ static int ret; | |||
52 | /** | 52 | /** |
53 | * Selected level of verbosity. | 53 | * Selected level of verbosity. |
54 | */ | 54 | */ |
55 | static int verbosity; | 55 | static unsigned int verbosity; |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -230,13 +230,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
230 | int | 230 | int |
231 | main (int argc, char *const *argv) | 231 | main (int argc, char *const *argv) |
232 | { | 232 | { |
233 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 233 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
234 | {'4', "ipv4", "IPV4", | 234 | GNUNET_GETOPT_OPTION_STRING ('4', |
235 | gettext_noop ("set A records"), | 235 | "ipv4", |
236 | 1, &GNUNET_GETOPT_set_string, &n4}, | 236 | "IPV4", |
237 | {'6', "ipv4", "IPV6", | 237 | gettext_noop ("set A records"), |
238 | gettext_noop ("set AAAA records"), | 238 | &n4), |
239 | 1, &GNUNET_GETOPT_set_string, &n6}, | 239 | |
240 | GNUNET_GETOPT_OPTION_STRING ('6', | ||
241 | "ipv4", | ||
242 | "IPV6", | ||
243 | gettext_noop ("set AAAA records"), | ||
244 | &n6), | ||
245 | |||
240 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 246 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
241 | GNUNET_GETOPT_OPTION_END | 247 | GNUNET_GETOPT_OPTION_END |
242 | }; | 248 | }; |
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index f78e311d3..bfe45957e 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_fs_service.h" | 27 | #include "gnunet_fs_service.h" |
28 | #include "gnunet_getopt_lib.h" | ||
28 | #include "fs_api.h" | 29 | #include "fs_api.h" |
29 | 30 | ||
30 | /* ******************** command-line option parsing API ******************** */ | 31 | /* ******************** command-line option parsing API ******************** */ |
@@ -41,10 +42,10 @@ | |||
41 | * @param value command line argument given | 42 | * @param value command line argument given |
42 | * @return GNUNET_OK on success | 43 | * @return GNUNET_OK on success |
43 | */ | 44 | */ |
44 | int | 45 | static int |
45 | GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | 46 | getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext |
46 | *ctx, void *scls, const char *option, | 47 | *ctx, void *scls, const char *option, |
47 | const char *value) | 48 | const char *value) |
48 | { | 49 | { |
49 | struct GNUNET_FS_Uri **uri = scls; | 50 | struct GNUNET_FS_Uri **uri = scls; |
50 | struct GNUNET_FS_Uri *u = *uri; | 51 | struct GNUNET_FS_Uri *u = *uri; |
@@ -107,6 +108,34 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
107 | return GNUNET_OK; | 108 | return GNUNET_OK; |
108 | } | 109 | } |
109 | 110 | ||
111 | /** | ||
112 | * Allow user to specify keywords. | ||
113 | * | ||
114 | * @param shortName short name of the option | ||
115 | * @param name long name of the option | ||
116 | * @param argumentHelp help text for the option argument | ||
117 | * @param description long help text for the option | ||
118 | * @param[out] topKeywords set to the desired value | ||
119 | */ | ||
120 | struct GNUNET_GETOPT_CommandLineOption | ||
121 | GNUNET_FS_GETOPT_KEYWORDS (char shortName, | ||
122 | const char *name, | ||
123 | const char *argumentHelp, | ||
124 | const char *description, | ||
125 | struct GNUNET_FS_Uri **topKeywords) | ||
126 | { | ||
127 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
128 | .shortName = shortName, | ||
129 | .name = name, | ||
130 | .argumentHelp = argumentHelp, | ||
131 | .description = description, | ||
132 | .require_argument = 1, | ||
133 | .processor = &getopt_set_keywords, | ||
134 | .scls = (void *) topKeywords | ||
135 | }; | ||
136 | |||
137 | return clo; | ||
138 | } | ||
110 | 139 | ||
111 | /** | 140 | /** |
112 | * Command-line option parser function that allows the user to specify | 141 | * Command-line option parser function that allows the user to specify |
@@ -120,11 +149,11 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
120 | * @param value command line argument given | 149 | * @param value command line argument given |
121 | * @return #GNUNET_OK on success | 150 | * @return #GNUNET_OK on success |
122 | */ | 151 | */ |
123 | int | 152 | static int |
124 | GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 153 | getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
125 | void *scls, | 154 | void *scls, |
126 | const char *option, | 155 | const char *option, |
127 | const char *value) | 156 | const char *value) |
128 | { | 157 | { |
129 | struct GNUNET_CONTAINER_MetaData **mm = scls; | 158 | struct GNUNET_CONTAINER_MetaData **mm = scls; |
130 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR | 159 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR |
@@ -200,4 +229,36 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
200 | return GNUNET_OK; | 229 | return GNUNET_OK; |
201 | } | 230 | } |
202 | 231 | ||
232 | /** | ||
233 | * Allow user to specify metadata. | ||
234 | * | ||
235 | * @param shortName short name of the option | ||
236 | * @param name long name of the option | ||
237 | * @param argumentHelp help text for the option argument | ||
238 | * @param description long help text for the option | ||
239 | * @param[out] metadata set to the desired value | ||
240 | */ | ||
241 | struct GNUNET_GETOPT_CommandLineOption | ||
242 | GNUNET_FS_GETOPT_METADATA (char shortName, | ||
243 | const char *name, | ||
244 | const char *argumentHelp, | ||
245 | const char *description, | ||
246 | struct GNUNET_CONTAINER_MetaData **meta) | ||
247 | { | ||
248 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
249 | .shortName = shortName, | ||
250 | .name = name, | ||
251 | .argumentHelp = argumentHelp, | ||
252 | .description = description, | ||
253 | .require_argument = 1, | ||
254 | .processor = &getopt_set_metadata, | ||
255 | .scls = (void *) meta | ||
256 | }; | ||
257 | |||
258 | return clo; | ||
259 | } | ||
260 | |||
261 | |||
262 | |||
263 | |||
203 | /* end of fs_getopt.c */ | 264 | /* end of fs_getopt.c */ |
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c index cc0111111..2f980520a 100644 --- a/src/fs/gnunet-auto-share.c +++ b/src/fs/gnunet-auto-share.c | |||
@@ -72,7 +72,7 @@ static int ret; | |||
72 | /** | 72 | /** |
73 | * Are we running 'verbosely'? | 73 | * Are we running 'verbosely'? |
74 | */ | 74 | */ |
75 | static int verbose; | 75 | static unsigned int verbose; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Configuration to use. | 78 | * Configuration to use. |
@@ -759,26 +759,38 @@ free_item (void *cls, | |||
759 | int | 759 | int |
760 | main (int argc, char *const *argv) | 760 | main (int argc, char *const *argv) |
761 | { | 761 | { |
762 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 762 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
763 | {'a', "anonymity", "LEVEL", | 763 | |
764 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 764 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
765 | 1, &GNUNET_GETOPT_set_uint, &anonymity_level}, | 765 | "anonymity", |
766 | {'d', "disable-creation-time", NULL, | 766 | "LEVEL", |
767 | gettext_noop | 767 | gettext_noop ("set the desired LEVEL of sender-anonymity"), |
768 | ("disable adding the creation time to the metadata of the uploaded file"), | 768 | &anonymity_level), |
769 | 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time}, | 769 | |
770 | {'D', "disable-extractor", NULL, | 770 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
771 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 771 | "disable-creation-time", |
772 | 0, &GNUNET_GETOPT_set_one, &disable_extractor}, | 772 | gettext_noop ("disable adding the creation time to the metadata of the uploaded file"), |
773 | {'p', "priority", "PRIORITY", | 773 | &do_disable_creation_time), |
774 | gettext_noop ("specify the priority of the content"), | 774 | |
775 | 1, &GNUNET_GETOPT_set_uint, &content_priority}, | 775 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
776 | {'r', "replication", "LEVEL", | 776 | "disable-extractor", |
777 | gettext_noop ("set the desired replication LEVEL"), | 777 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
778 | 1, &GNUNET_GETOPT_set_uint, &replication_level}, | 778 | &disable_extractor), |
779 | {'V', "verbose", NULL, | 779 | |
780 | gettext_noop ("be verbose (print progress information)"), | 780 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
781 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 781 | "priority", |
782 | "PRIORITY", | ||
783 | gettext_noop ("specify the priority of the content"), | ||
784 | &content_priority), | ||
785 | |||
786 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
787 | "replication", | ||
788 | "LEVEL", | ||
789 | gettext_noop ("set the desired replication LEVEL"), | ||
790 | &replication_level), | ||
791 | |||
792 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
793 | |||
782 | GNUNET_GETOPT_OPTION_END | 794 | GNUNET_GETOPT_OPTION_END |
783 | }; | 795 | }; |
784 | struct WorkItem *wi; | 796 | struct WorkItem *wi; |
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index 6d9adb8ab..4d6f30587 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | static int ret; | 31 | static int ret; |
32 | 32 | ||
33 | static int verbose; | 33 | static unsigned int verbose; |
34 | 34 | ||
35 | static int delete_incomplete; | 35 | static int delete_incomplete; |
36 | 36 | ||
@@ -299,33 +299,51 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
299 | int | 299 | int |
300 | main (int argc, char *const *argv) | 300 | main (int argc, char *const *argv) |
301 | { | 301 | { |
302 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 302 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
303 | {'a', "anonymity", "LEVEL", | 303 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
304 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 304 | "anonymity", |
305 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 305 | "LEVEL", |
306 | {'D', "delete-incomplete", NULL, | 306 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
307 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), | 307 | &anonymity), |
308 | 0, &GNUNET_GETOPT_set_one, &delete_incomplete}, | 308 | |
309 | {'n', "no-network", NULL, | 309 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
310 | gettext_noop ("only search the local peer (no P2P network search)"), | 310 | "delete-incomplete", |
311 | 0, &GNUNET_GETOPT_set_one, &local_only}, | 311 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), |
312 | {'o', "output", "FILENAME", | 312 | &delete_incomplete), |
313 | gettext_noop ("write the file to FILENAME"), | 313 | |
314 | 1, &GNUNET_GETOPT_set_string, &filename}, | 314 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
315 | {'p', "parallelism", "DOWNLOADS", | 315 | "no-network", |
316 | gettext_noop | 316 | gettext_noop ("only search the local peer (no P2P network search)"), |
317 | ("set the maximum number of parallel downloads that is allowed"), | 317 | &local_only), |
318 | 1, &GNUNET_GETOPT_set_uint, ¶llelism}, | 318 | |
319 | {'r', "request-parallelism", "REQUESTS", | 319 | GNUNET_GETOPT_OPTION_STRING ('o', |
320 | gettext_noop | 320 | "output", |
321 | ("set the maximum number of parallel requests for blocks that is allowed"), | 321 | "FILENAME", |
322 | 1, &GNUNET_GETOPT_set_uint, &request_parallelism}, | 322 | gettext_noop ("write the file to FILENAME"), |
323 | {'R', "recursive", NULL, | 323 | &filename), |
324 | gettext_noop ("download a GNUnet directory recursively"), | 324 | |
325 | 0, &GNUNET_GETOPT_set_one, &do_recursive}, | 325 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
326 | {'V', "verbose", NULL, | 326 | "parallelism", |
327 | gettext_noop ("be verbose (print progress information)"), | 327 | "DOWNLOADS", |
328 | 0, &GNUNET_GETOPT_increment_value, &verbose}, | 328 | gettext_noop ("set the maximum number of parallel downloads that is allowed"), |
329 | ¶llelism), | ||
330 | |||
331 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
332 | "request-parallelism", | ||
333 | "REQUESTS", | ||
334 | gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"), | ||
335 | &request_parallelism), | ||
336 | |||
337 | GNUNET_GETOPT_OPTION_SET_ONE ('R', | ||
338 | "recursive", | ||
339 | gettext_noop ("download a GNUnet directory recursively"), | ||
340 | &do_recursive), | ||
341 | |||
342 | GNUNET_GETOPT_OPTION_INCREMENT_VALUE ('V', | ||
343 | "verbose", | ||
344 | gettext_noop ("be verbose (print progress information)"), | ||
345 | &verbose), | ||
346 | |||
329 | GNUNET_GETOPT_OPTION_END | 347 | GNUNET_GETOPT_OPTION_END |
330 | }; | 348 | }; |
331 | 349 | ||
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c index cfbe57bbd..fb99d8f90 100644 --- a/src/fs/gnunet-fs-profiler.c +++ b/src/fs/gnunet-fs-profiler.c | |||
@@ -203,16 +203,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
203 | int | 203 | int |
204 | main (int argc, char *const *argv) | 204 | main (int argc, char *const *argv) |
205 | { | 205 | { |
206 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 206 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
207 | {'n', "num-peers", "COUNT", | 207 | |
208 | gettext_noop ("run the experiment with COUNT peers"), | 208 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
209 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | 209 | "num-peers", |
210 | {'H', "hosts", "HOSTFILE", | 210 | "COUNT", |
211 | gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), | 211 | gettext_noop ("run the experiment with COUNT peers"), |
212 | 1, &GNUNET_GETOPT_set_string, &host_filename}, | 212 | &num_peers), |
213 | {'t', "timeout", "DELAY", | 213 | |
214 | gettext_noop ("automatically terminate experiment after DELAY"), | 214 | GNUNET_GETOPT_OPTION_STRING ('H', |
215 | 1, &GNUNET_GETOPT_set_relative_time, &timeout}, | 215 | "hosts", |
216 | "HOSTFILE", | ||
217 | gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), | ||
218 | &host_filename), | ||
219 | |||
220 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
221 | "timeout", | ||
222 | "DELAY", | ||
223 | gettext_noop ("automatically terminate experiment after DELAY"), | ||
224 | &timeout), | ||
225 | |||
216 | GNUNET_GETOPT_OPTION_END | 226 | GNUNET_GETOPT_OPTION_END |
217 | }; | 227 | }; |
218 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 228 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index 7c20e025f..2b24b7124 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c | |||
@@ -43,7 +43,7 @@ static int list_indexed_files; | |||
43 | /** | 43 | /** |
44 | * Option -v given? | 44 | * Option -v given? |
45 | */ | 45 | */ |
46 | static int verbose; | 46 | static unsigned int verbose; |
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
@@ -112,10 +112,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
112 | int | 112 | int |
113 | main (int argc, char *const *argv) | 113 | main (int argc, char *const *argv) |
114 | { | 114 | { |
115 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 115 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
116 | {'i', "list-indexed", NULL, | 116 | |
117 | gettext_noop ("print a list of all indexed files"), 0, | 117 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
118 | &GNUNET_GETOPT_set_one, &list_indexed_files}, | 118 | "list-indexed", |
119 | gettext_noop ("print a list of all indexed files"), | ||
120 | &list_indexed_files), | ||
121 | |||
119 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | 122 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), |
120 | GNUNET_GETOPT_OPTION_END | 123 | GNUNET_GETOPT_OPTION_END |
121 | }; | 124 | }; |
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index a563d7b7a..2229e45e7 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -37,7 +37,7 @@ static int ret; | |||
37 | /** | 37 | /** |
38 | * Command line option 'verbose' set | 38 | * Command line option 'verbose' set |
39 | */ | 39 | */ |
40 | static int verbose; | 40 | static unsigned int verbose; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Handle to our configuration. | 43 | * Handle to our configuration. |
@@ -893,63 +893,98 @@ run (void *cls, | |||
893 | int | 893 | int |
894 | main (int argc, char *const *argv) | 894 | main (int argc, char *const *argv) |
895 | { | 895 | { |
896 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 896 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
897 | {'a', "anonymity", "LEVEL", | 897 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
898 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 898 | "anonymity", |
899 | 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level}, | 899 | "LEVEL", |
900 | {'d', "disable-creation-time", NULL, | 900 | gettext_noop ("set the desired LEVEL of sender-anonymity"), |
901 | gettext_noop | 901 | &bo.anonymity_level), |
902 | ("disable adding the creation time to the metadata of the uploaded file"), | 902 | |
903 | 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time}, | 903 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
904 | {'D', "disable-extractor", NULL, | 904 | "disable-creation-time", |
905 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 905 | gettext_noop ("disable adding the creation time to the " |
906 | 0, &GNUNET_GETOPT_set_one, &disable_extractor}, | 906 | "metadata of the uploaded file"), |
907 | {'e', "extract", NULL, | 907 | &do_disable_creation_time), |
908 | gettext_noop | 908 | |
909 | ("print list of extracted keywords that would be used, but do not perform upload"), | 909 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
910 | 0, &GNUNET_GETOPT_set_one, &extract_only}, | 910 | "disable-extractor", |
911 | {'k', "key", "KEYWORD", | 911 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
912 | gettext_noop | 912 | &disable_extractor), |
913 | ("add an additional keyword for the top-level file or directory" | 913 | |
914 | " (this option can be specified multiple times)"), | 914 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
915 | 1, &GNUNET_FS_getopt_set_keywords, &topKeywords}, | 915 | "extract", |
916 | {'m', "meta", "TYPE:VALUE", | 916 | gettext_noop ("print list of extracted keywords that would " |
917 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), | 917 | "be used, but do not perform upload"), |
918 | 1, &GNUNET_FS_getopt_set_metadata, &meta}, | 918 | &extract_only), |
919 | {'n', "noindex", NULL, | 919 | |
920 | gettext_noop ("do not index, perform full insertion (stores entire " | 920 | GNUNET_FS_GETOPT_KEYWORDS ('k', |
921 | "file in encrypted form in GNUnet database)"), | 921 | "key", |
922 | 0, &GNUNET_GETOPT_set_one, &do_insert}, | 922 | "KEYWORD", |
923 | {'N', "next", "ID", | 923 | gettext_noop ("add an additional keyword for the top-level " |
924 | gettext_noop | 924 | "file or directory (this option can be specified multiple times)"), |
925 | ("specify ID of an updated version to be published in the future" | 925 | &topKeywords), |
926 | " (for namespace insertions only)"), | 926 | |
927 | 1, &GNUNET_GETOPT_set_string, &next_id}, | 927 | GNUNET_FS_GETOPT_METADATA ('m', |
928 | {'p', "priority", "PRIORITY", | 928 | "meta", |
929 | gettext_noop ("specify the priority of the content"), | 929 | "TYPE:VALUE", |
930 | 1, &GNUNET_GETOPT_set_uint, &bo.content_priority}, | 930 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
931 | {'P', "pseudonym", "NAME", | 931 | &meta), |
932 | gettext_noop | 932 | |
933 | ("publish the files under the pseudonym NAME (place file into namespace)"), | 933 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
934 | 1, &GNUNET_GETOPT_set_string, &pseudonym}, | 934 | "noindex", |
935 | {'r', "replication", "LEVEL", | 935 | gettext_noop ("do not index, perform full insertion (stores " |
936 | gettext_noop ("set the desired replication LEVEL"), | 936 | "entire file in encrypted form in GNUnet database)"), |
937 | 1, &GNUNET_GETOPT_set_uint, &bo.replication_level}, | 937 | &do_insert), |
938 | {'s', "simulate-only", NULL, | 938 | |
939 | gettext_noop ("only simulate the process but do not do any " | 939 | GNUNET_GETOPT_OPTION_STRING ('N', |
940 | "actual publishing (useful to compute URIs)"), | 940 | "next", |
941 | 0, &GNUNET_GETOPT_set_one, &do_simulate}, | 941 | "ID", |
942 | {'t', "this", "ID", | 942 | gettext_noop ("specify ID of an updated version to be " |
943 | gettext_noop ("set the ID of this version of the publication" | 943 | "published in the future (for namespace insertions only)"), |
944 | " (for namespace insertions only)"), | 944 | &next_id), |
945 | 1, &GNUNET_GETOPT_set_string, &this_id}, | 945 | |
946 | {'u', "uri", "URI", | 946 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
947 | gettext_noop ("URI to be published (can be used instead of passing a " | 947 | "priority", |
948 | "file to add keywords to the file with the respective URI)"), | 948 | "PRIORITY", |
949 | 1, &GNUNET_GETOPT_set_string, &uri_string}, | 949 | gettext_noop ("specify the priority of the content"), |
950 | {'V', "verbose", NULL, | 950 | &bo.content_priority), |
951 | gettext_noop ("be verbose (print progress information)"), | 951 | |
952 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 952 | GNUNET_GETOPT_OPTION_STRING ('P', |
953 | "pseudonym", | ||
954 | "NAME", | ||
955 | gettext_noop ("publish the files under the pseudonym " | ||
956 | "NAME (place file into namespace)"), | ||
957 | &pseudonym), | ||
958 | |||
959 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
960 | "replication", | ||
961 | "LEVEL", | ||
962 | gettext_noop ("set the desired replication LEVEL"), | ||
963 | &bo.replication_level), | ||
964 | |||
965 | |||
966 | GNUNET_GETOPT_OPTION_SET_ONE ('s', | ||
967 | "simulate-only", | ||
968 | gettext_noop ("only simulate the process but do not do " | ||
969 | "any actual publishing (useful to compute URIs)"), | ||
970 | &do_simulate), | ||
971 | |||
972 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
973 | "this", | ||
974 | "ID", | ||
975 | gettext_noop ("set the ID of this version of the publication " | ||
976 | "(for namespace insertions only)"), | ||
977 | &this_id), | ||
978 | |||
979 | GNUNET_GETOPT_OPTION_STRING ('u', | ||
980 | "uri", | ||
981 | "URI", | ||
982 | gettext_noop ("URI to be published (can be used instead of passing a " | ||
983 | "file to add keywords to the file with the respective URI)"), | ||
984 | &uri_string), | ||
985 | |||
986 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
987 | |||
953 | GNUNET_GETOPT_OPTION_END | 988 | GNUNET_GETOPT_OPTION_END |
954 | }; | 989 | }; |
955 | bo.expiration_time = | 990 | bo.expiration_time = |
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index dfe6d0e75..22e790cf3 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -51,7 +51,7 @@ static unsigned int results_limit; | |||
51 | 51 | ||
52 | static unsigned int results; | 52 | static unsigned int results; |
53 | 53 | ||
54 | static int verbose; | 54 | static unsigned int verbose; |
55 | 55 | ||
56 | static int local_only; | 56 | static int local_only; |
57 | 57 | ||
@@ -305,26 +305,42 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
305 | int | 305 | int |
306 | main (int argc, char *const *argv) | 306 | main (int argc, char *const *argv) |
307 | { | 307 | { |
308 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 308 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
309 | {'a', "anonymity", "LEVEL", | 309 | |
310 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 310 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
311 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 311 | "anonymity", |
312 | {'n', "no-network", NULL, | 312 | "LEVEL", |
313 | gettext_noop ("only search the local peer (no P2P network search)"), | 313 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
314 | 0, &GNUNET_GETOPT_set_one, &local_only}, | 314 | &anonymity), |
315 | {'o', "output", "PREFIX", | 315 | |
316 | gettext_noop ("write search results to file starting with PREFIX"), | 316 | |
317 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | 317 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
318 | {'t', "timeout", "DELAY", | 318 | "no-network", |
319 | gettext_noop ("automatically terminate search after DELAY"), | 319 | gettext_noop ("only search the local peer (no P2P network search)"), |
320 | 1, &GNUNET_GETOPT_set_relative_time, &timeout}, | 320 | &local_only), |
321 | {'V', "verbose", NULL, | 321 | |
322 | gettext_noop ("be verbose (print progress information)"), | 322 | GNUNET_GETOPT_OPTION_STRING ('o', |
323 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 323 | "output", |
324 | {'N', "results", "VALUE", | 324 | "PREFIX", |
325 | gettext_noop | 325 | gettext_noop ("write search results to file starting with PREFIX"), |
326 | ("automatically terminate search after VALUE results are found"), | 326 | &output_filename), |
327 | 1, &GNUNET_GETOPT_set_uint, &results_limit}, | 327 | |
328 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
329 | "timeout", | ||
330 | "DELAY", | ||
331 | gettext_noop ("automatically terminate search after DELAY"), | ||
332 | &timeout), | ||
333 | |||
334 | |||
335 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
336 | |||
337 | GNUNET_GETOPT_OPTION_SET_UINT ('N', | ||
338 | "results", | ||
339 | "VALUE", | ||
340 | gettext_noop ("automatically terminate search " | ||
341 | "after VALUE results are found"), | ||
342 | &results_limit), | ||
343 | |||
328 | GNUNET_GETOPT_OPTION_END | 344 | GNUNET_GETOPT_OPTION_END |
329 | }; | 345 | }; |
330 | 346 | ||
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 40fa13b62..c53a85fb4 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | static int ret; | 31 | static int ret; |
32 | 32 | ||
33 | static int verbose; | 33 | static unsigned int verbose; |
34 | 34 | ||
35 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 35 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
36 | 36 | ||
@@ -162,10 +162,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
162 | int | 162 | int |
163 | main (int argc, char *const *argv) | 163 | main (int argc, char *const *argv) |
164 | { | 164 | { |
165 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 165 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
166 | {'V', "verbose", NULL, | 166 | |
167 | gettext_noop ("be verbose (print progress information)"), | 167 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), |
168 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 168 | |
169 | GNUNET_GETOPT_OPTION_END | 169 | GNUNET_GETOPT_OPTION_END |
170 | }; | 170 | }; |
171 | 171 | ||
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c index 21471350d..fb7ac10c1 100644 --- a/src/gns/gnunet-bcd.c +++ b/src/gns/gnunet-bcd.c | |||
@@ -514,10 +514,14 @@ run (void *cls, | |||
514 | int | 514 | int |
515 | main (int argc, char *const *argv) | 515 | main (int argc, char *const *argv) |
516 | { | 516 | { |
517 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 517 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
518 | {'p', "port", "PORT", | 518 | |
519 | gettext_noop ("Run HTTP serve on port PORT (default is 8888)"), 1, | 519 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
520 | &GNUNET_GETOPT_set_uint, &port}, | 520 | "port", |
521 | "PORT", | ||
522 | gettext_noop ("Run HTTP serve on port PORT (default is 8888)"), | ||
523 | &port), | ||
524 | |||
521 | GNUNET_GETOPT_OPTION_END | 525 | GNUNET_GETOPT_OPTION_END |
522 | }; | 526 | }; |
523 | int ret; | 527 | int ret; |
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 813ecdf8e..c9b4bde9c 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -776,22 +776,38 @@ int | |||
776 | main (int argc, | 776 | main (int argc, |
777 | char *const *argv) | 777 | char *const *argv) |
778 | { | 778 | { |
779 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 779 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
780 | {'d', "dns", "IP", | 780 | |
781 | gettext_noop ("IP of recursive DNS resolver to use (required)"), 1, | 781 | GNUNET_GETOPT_OPTION_STRING ('d', |
782 | &GNUNET_GETOPT_set_string, &dns_ip}, | 782 | "dns", |
783 | {'f', "fcfs", "NAME", | 783 | "IP", |
784 | gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"), 1, | 784 | gettext_noop ("IP of recursive DNS resolver to use (required)"), |
785 | &GNUNET_GETOPT_set_string, &fcfs_suffix}, | 785 | &dns_ip), |
786 | {'s', "suffix", "SUFFIX", | 786 | |
787 | gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), 1, | 787 | GNUNET_GETOPT_OPTION_STRING ('f', |
788 | &GNUNET_GETOPT_set_string, &dns_suffix}, | 788 | "fcfs", |
789 | {'p', "port", "UDPPORT", | 789 | "NAME", |
790 | gettext_noop ("UDP port to listen on for inbound DNS requests; default: 2853"), 1, | 790 | gettext_noop ("Authoritative FCFS suffix to use (optional); default: fcfs.zkey.eu"), |
791 | &GNUNET_GETOPT_set_uint, &listen_port}, | 791 | &fcfs_suffix), |
792 | {'z', "zone", "PUBLICKEY", | 792 | |
793 | gettext_noop ("Public key of the GNS zone to use (overrides default)"), 1, | 793 | GNUNET_GETOPT_OPTION_STRING ('s', |
794 | &GNUNET_GETOPT_set_string, &gns_zone_str}, | 794 | "suffix", |
795 | "SUFFIX", | ||
796 | gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), | ||
797 | &dns_suffix), | ||
798 | |||
799 | GNUNET_GETOPT_OPTION_SET_UINT ('p', | ||
800 | "port", | ||
801 | "UDPPORT", | ||
802 | gettext_noop ("UDP port to listen on for inbound DNS requests; default: 2853"), | ||
803 | &listen_port), | ||
804 | |||
805 | GNUNET_GETOPT_OPTION_STRING ('z', | ||
806 | "zone", | ||
807 | "PUBLICKEY", | ||
808 | gettext_noop ("Public key of the GNS zone to use (overrides default)"), | ||
809 | &gns_zone_str), | ||
810 | |||
795 | GNUNET_GETOPT_OPTION_END | 811 | GNUNET_GETOPT_OPTION_END |
796 | }; | 812 | }; |
797 | int ret; | 813 | int ret; |
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index c336848ce..35f42cdec 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -621,7 +621,7 @@ struct Socks5Request | |||
621 | /** | 621 | /** |
622 | * The port the proxy is running on (default 7777) | 622 | * The port the proxy is running on (default 7777) |
623 | */ | 623 | */ |
624 | static unsigned long port = GNUNET_GNS_PROXY_PORT; | 624 | static unsigned long long port = GNUNET_GNS_PROXY_PORT; |
625 | 625 | ||
626 | /** | 626 | /** |
627 | * The CA file (pem) to use for the proxy CA | 627 | * The CA file (pem) to use for the proxy CA |
@@ -3108,7 +3108,7 @@ run_cont () | |||
3108 | return; | 3108 | return; |
3109 | } | 3109 | } |
3110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3111 | "Proxy listens on port %lu\n", | 3111 | "Proxy listens on port %llu\n", |
3112 | port); | 3112 | port); |
3113 | 3113 | ||
3114 | /* start MHD daemon for HTTP */ | 3114 | /* start MHD daemon for HTTP */ |
@@ -3261,13 +3261,20 @@ run (void *cls, | |||
3261 | int | 3261 | int |
3262 | main (int argc, char *const *argv) | 3262 | main (int argc, char *const *argv) |
3263 | { | 3263 | { |
3264 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 3264 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
3265 | {'p', "port", NULL, | 3265 | |
3266 | gettext_noop ("listen on specified port (default: 7777)"), 1, | 3266 | GNUNET_GETOPT_OPTION_SET_ULONG ('p', |
3267 | &GNUNET_GETOPT_set_ulong, &port}, | 3267 | "port", |
3268 | {'a', "authority", NULL, | 3268 | NULL, |
3269 | gettext_noop ("pem file to use as CA"), 1, | 3269 | gettext_noop ("listen on specified port (default: 7777)"), |
3270 | &GNUNET_GETOPT_set_string, &cafile_opt}, | 3270 | &port), |
3271 | |||
3272 | GNUNET_GETOPT_OPTION_STRING ('a', | ||
3273 | "authority", | ||
3274 | NULL, | ||
3275 | gettext_noop ("pem file to use as CA"), | ||
3276 | &cafile_opt), | ||
3277 | |||
3271 | GNUNET_GETOPT_OPTION_END | 3278 | GNUNET_GETOPT_OPTION_END |
3272 | }; | 3279 | }; |
3273 | static const char* page = | 3280 | static const char* page = |
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index a261e008b..c85ddfe81 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -420,25 +420,43 @@ int | |||
420 | main (int argc, | 420 | main (int argc, |
421 | char *const *argv) | 421 | char *const *argv) |
422 | { | 422 | { |
423 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 423 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
424 | {'u', "lookup", "NAME", | 424 | |
425 | gettext_noop ("Lookup a record for the given name"), 1, | 425 | GNUNET_GETOPT_OPTION_STRING ('u', |
426 | &GNUNET_GETOPT_set_string, &lookup_name}, | 426 | "lookup", |
427 | {'t', "type", "TYPE", | 427 | "NAME", |
428 | gettext_noop ("Specify the type of the record to lookup"), 1, | 428 | gettext_noop ("Lookup a record for the given name"), |
429 | &GNUNET_GETOPT_set_string, &lookup_type}, | 429 | &lookup_name), |
430 | { 'T', "timeout", "DELAY", | 430 | |
431 | gettext_noop ("Specify timeout for the lookup"), 1, | 431 | GNUNET_GETOPT_OPTION_STRING ('t', |
432 | &GNUNET_GETOPT_set_relative_time, &timeout }, | 432 | "type", |
433 | {'r', "raw", NULL, | 433 | "TYPE", |
434 | gettext_noop ("No unneeded output"), 0, | 434 | gettext_noop ("Specify the type of the record to lookup"), |
435 | &GNUNET_GETOPT_set_one, &raw}, | 435 | &lookup_type), |
436 | {'p', "public-key", "PKEY", | 436 | |
437 | gettext_noop ("Specify the public key of the zone to lookup the record in"), 1, | 437 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('T', |
438 | &GNUNET_GETOPT_set_string, &public_key}, | 438 | "timeout", |
439 | {'z', "zone", "NAME", | 439 | "DELAY", |
440 | gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), 1, | 440 | gettext_noop ("Specify timeout for the lookup"), |
441 | &GNUNET_GETOPT_set_string, &zone_ego_name}, | 441 | &timeout), |
442 | |||
443 | GNUNET_GETOPT_OPTION_SET_ONE ('r', | ||
444 | "raw", | ||
445 | gettext_noop ("No unneeded output"), | ||
446 | &raw), | ||
447 | |||
448 | GNUNET_GETOPT_OPTION_STRING ('p', | ||
449 | "public-key", | ||
450 | "PKEY", | ||
451 | gettext_noop ("Specify the public key of the zone to lookup the record in"), | ||
452 | &public_key), | ||
453 | |||
454 | GNUNET_GETOPT_OPTION_STRING ('z', | ||
455 | "zone", | ||
456 | "NAME", | ||
457 | gettext_noop ("Specify the name of the ego of the zone to lookup the record in"), | ||
458 | &zone_ego_name), | ||
459 | |||
442 | GNUNET_GETOPT_OPTION_END | 460 | GNUNET_GETOPT_OPTION_END |
443 | }; | 461 | }; |
444 | int ret; | 462 | int ret; |
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index a83d46e07..9b4790c32 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -369,23 +369,26 @@ run (void *cls, | |||
369 | int | 369 | int |
370 | main (int argc, char *const *argv) | 370 | main (int argc, char *const *argv) |
371 | { | 371 | { |
372 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 372 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
373 | #if HAVE_MHD | 373 | #if HAVE_MHD |
374 | {'a', "advertise", NULL, | 374 | GNUNET_GETOPT_OPTION_SET_ONE ('a', |
375 | gettext_noop ("advertise our hostlist to other peers"), | 375 | "advertise", |
376 | GNUNET_NO, &GNUNET_GETOPT_set_one, &advertising}, | 376 | gettext_noop ("advertise our hostlist to other peers"), |
377 | &advertising), | ||
377 | #endif | 378 | #endif |
378 | {'b', "bootstrap", NULL, | 379 | GNUNET_GETOPT_OPTION_SET_ONE ('b', |
379 | gettext_noop | 380 | "bootstrap", |
380 | ("bootstrap using hostlists (it is highly recommended that you always use this option)"), | 381 | gettext_noop ("bootstrap using hostlists (it is highly recommended that you always use this option)"), |
381 | GNUNET_NO, &GNUNET_GETOPT_set_one, &bootstrapping}, | 382 | &bootstrapping), |
382 | {'e', "enable-learning", NULL, | 383 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
383 | gettext_noop ("enable learning about hostlist servers from other peers"), | 384 | "enable-learning", |
384 | GNUNET_NO, &GNUNET_GETOPT_set_one, &learning}, | 385 | gettext_noop ("enable learning about hostlist servers from other peers"), |
386 | &learning), | ||
385 | #if HAVE_MHD | 387 | #if HAVE_MHD |
386 | {'p', "provide-hostlist", NULL, | 388 | GNUNET_GETOPT_OPTION_SET_ONE ('p', |
387 | gettext_noop ("provide a hostlist server"), | 389 | "provide-hostlist", |
388 | GNUNET_NO, &GNUNET_GETOPT_set_one, &provide_hostlist}, | 390 | gettext_noop ("provide a hostlist server"), |
391 | &provide_hostlist), | ||
389 | #endif | 392 | #endif |
390 | GNUNET_GETOPT_OPTION_END | 393 | GNUNET_GETOPT_OPTION_END |
391 | }; | 394 | }; |
diff --git a/src/identity-provider/gnunet-identity-token.c b/src/identity-provider/gnunet-identity-token.c index 4bb3292be..906899ea7 100644 --- a/src/identity-provider/gnunet-identity-token.c +++ b/src/identity-provider/gnunet-identity-token.c | |||
@@ -158,13 +158,18 @@ run (void *cls, | |||
158 | int | 158 | int |
159 | main(int argc, char *const argv[]) | 159 | main(int argc, char *const argv[]) |
160 | { | 160 | { |
161 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 161 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
162 | {'t', "token", NULL, | 162 | |
163 | gettext_noop ("GNUid token"), 1, | 163 | GNUNET_GETOPT_OPTION_STRING ('t', |
164 | &GNUNET_GETOPT_set_string, &token}, | 164 | "token", |
165 | {'p', "print", NULL, | 165 | NULL, |
166 | gettext_noop ("Print token contents"), 0, | 166 | gettext_noop ("GNUid token"), |
167 | &GNUNET_GETOPT_set_one, &print_token}, | 167 | &token), |
168 | |||
169 | GNUNET_GETOPT_OPTION_SET_ONE ('p', | ||
170 | "print", | ||
171 | gettext_noop ("Print token contents"), | ||
172 | &print_token), | ||
168 | 173 | ||
169 | GNUNET_GETOPT_OPTION_END | 174 | GNUNET_GETOPT_OPTION_END |
170 | }; | 175 | }; |
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index 8c8485249..5c457ef5d 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c | |||
@@ -349,25 +349,41 @@ run (void *cls, | |||
349 | int | 349 | int |
350 | main (int argc, char *const *argv) | 350 | main (int argc, char *const *argv) |
351 | { | 351 | { |
352 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 352 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
353 | {'C', "create", "NAME", | 353 | GNUNET_GETOPT_OPTION_STRING ('C', |
354 | gettext_noop ("create ego NAME"), | 354 | "create", |
355 | 1, &GNUNET_GETOPT_set_string, &create_ego}, | 355 | "NAME", |
356 | {'D', "delete", "NAME", | 356 | gettext_noop ("create ego NAME"), |
357 | gettext_noop ("delete ego NAME "), | 357 | &create_ego), |
358 | 1, &GNUNET_GETOPT_set_string, &delete_ego}, | 358 | |
359 | {'d', "display", NULL, | 359 | GNUNET_GETOPT_OPTION_STRING ('D', |
360 | gettext_noop ("display all egos"), | 360 | "delete", |
361 | 0, &GNUNET_GETOPT_set_one, &list}, | 361 | "NAME", |
362 | {'e', "ego", "NAME", | 362 | gettext_noop ("delete ego NAME "), |
363 | gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -s)"), | 363 | &delete_ego), |
364 | 1, &GNUNET_GETOPT_set_string, &set_ego}, | 364 | |
365 | {'m', "monitor", NULL, | 365 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
366 | gettext_noop ("run in monitor mode egos"), | 366 | "display", |
367 | 0, &GNUNET_GETOPT_set_one, &monitor}, | 367 | gettext_noop ("display all egos"), |
368 | {'s', "set", "SUBSYSTEM", | 368 | &list), |
369 | gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"), | 369 | |
370 | 1, &GNUNET_GETOPT_set_string, &set_subsystem}, | 370 | GNUNET_GETOPT_OPTION_STRING ('e', |
371 | "ego", | ||
372 | "NAME", | ||
373 | gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -s)"), | ||
374 | &set_ego), | ||
375 | |||
376 | GNUNET_GETOPT_OPTION_SET_ONE ('m', | ||
377 | "monitor", | ||
378 | gettext_noop ("run in monitor mode egos"), | ||
379 | &monitor), | ||
380 | |||
381 | GNUNET_GETOPT_OPTION_STRING ('s', | ||
382 | "set", | ||
383 | "SUBSYSTEM", | ||
384 | gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"), | ||
385 | &set_subsystem), | ||
386 | |||
371 | GNUNET_GETOPT_OPTION_END | 387 | GNUNET_GETOPT_OPTION_END |
372 | }; | 388 | }; |
373 | int res; | 389 | int res; |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index a9c7e8944..ac418072e 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -438,23 +438,36 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData | |||
438 | /* ******************** command-line option parsing API *********************** */ | 438 | /* ******************** command-line option parsing API *********************** */ |
439 | 439 | ||
440 | /** | 440 | /** |
441 | * Command-line option parser function that allows the user | 441 | * Allow user to specify keywords. |
442 | * to specify one or more '-k' options with keywords. Each | 442 | * |
443 | * specified keyword will be added to the URI. A pointer to | 443 | * @param shortName short name of the option |
444 | * the URI must be passed as the "scls" argument. | 444 | * @param name long name of the option |
445 | * | 445 | * @param argumentHelp help text for the option argument |
446 | * @param ctx command line processor context | 446 | * @param description long help text for the option |
447 | * @param scls must be of type "struct GNUNET_FS_Uri **" | 447 | * @param[out] topKeywords set to the desired value |
448 | * @param option name of the option (typically 'k') | 448 | */ |
449 | * @param value command line argument given | 449 | struct GNUNET_GETOPT_CommandLineOption |
450 | * @return #GNUNET_OK on success | 450 | GNUNET_FS_GETOPT_KEYWORDS (char shortName, |
451 | */ | 451 | const char *name, |
452 | int | 452 | const char *argumentHelp, |
453 | GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 453 | const char *description, |
454 | void *scls, | 454 | struct GNUNET_FS_Uri **topKeywords); |
455 | const char *option, | 455 | |
456 | const char *value); | 456 | /** |
457 | 457 | * Allow user to specify metadata. | |
458 | * | ||
459 | * @param shortName short name of the option | ||
460 | * @param name long name of the option | ||
461 | * @param argumentHelp help text for the option argument | ||
462 | * @param description long help text for the option | ||
463 | * @param[out] metadata set to the desired value | ||
464 | */ | ||
465 | struct GNUNET_GETOPT_CommandLineOption | ||
466 | GNUNET_FS_GETOPT_METADATA (char shortName, | ||
467 | const char *name, | ||
468 | const char *argumentHelp, | ||
469 | const char *description, | ||
470 | struct GNUNET_CONTAINER_MetaData **meta); | ||
458 | 471 | ||
459 | /** | 472 | /** |
460 | * Command-line option parser function that allows the user to specify | 473 | * Command-line option parser function that allows the user to specify |
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index b04020a70..c2bd72340 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h | |||
@@ -97,6 +97,7 @@ typedef int | |||
97 | const char *option, | 97 | const char *option, |
98 | const char *value); | 98 | const char *value); |
99 | 99 | ||
100 | |||
100 | /** | 101 | /** |
101 | * @brief Definition of a command line option. | 102 | * @brief Definition of a command line option. |
102 | */ | 103 | */ |
@@ -130,255 +131,301 @@ struct GNUNET_GETOPT_CommandLineOption | |||
130 | int require_argument; | 131 | int require_argument; |
131 | 132 | ||
132 | /** | 133 | /** |
134 | * Is the presence of this option mandatory? | ||
135 | */ | ||
136 | int option_mandatory; | ||
137 | |||
138 | /** | ||
133 | * Handler for the option. | 139 | * Handler for the option. |
134 | */ | 140 | */ |
135 | GNUNET_GETOPT_CommandLineOptionProcessor processor; | 141 | GNUNET_GETOPT_CommandLineOptionProcessor processor; |
136 | 142 | ||
137 | /** | 143 | /** |
144 | * Function to call on @e scls to clean up after processing all | ||
145 | * the arguments. Can be NULL. | ||
146 | */ | ||
147 | void (*cleaner)(void *cls); | ||
148 | |||
149 | /** | ||
138 | * Specific closure to pass to the processor. | 150 | * Specific closure to pass to the processor. |
139 | */ | 151 | */ |
140 | void *scls; | 152 | void *scls; |
141 | 153 | ||
142 | }; | 154 | }; |
143 | 155 | ||
156 | |||
144 | /** | 157 | /** |
145 | * Macro defining the option to print the command line | 158 | * Defining the option to print the command line |
146 | * help text (-h option). | 159 | * help text (-h option). |
147 | * | 160 | * |
148 | * @param about string with brief description of the application | 161 | * @param about string with brief description of the application |
149 | */ | 162 | */ |
150 | #define GNUNET_GETOPT_OPTION_HELP(about) \ | 163 | struct GNUNET_GETOPT_CommandLineOption |
151 | { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, &GNUNET_GETOPT_format_help_, (void *) about } | 164 | GNUNET_GETOPT_OPTION_HELP (const char *about); |
152 | 165 | ||
153 | 166 | ||
154 | /** | 167 | /** |
155 | * Macro defining the option to print the version of | 168 | * Define the option to print the version of |
156 | * the application (-v option) | 169 | * the application (-v option) |
157 | * | 170 | * |
158 | * @param version string with the version number | 171 | * @param version string with the version number |
159 | */ | 172 | */ |
160 | #define GNUNET_GETOPT_OPTION_VERSION(version) \ | 173 | struct GNUNET_GETOPT_CommandLineOption |
161 | { 'v', "version", (const char *) NULL, gettext_noop("print the version number"), 0, &GNUNET_GETOPT_print_version_, (void *) version } | 174 | GNUNET_GETOPT_OPTION_VERSION (const char *version); |
175 | |||
162 | 176 | ||
163 | 177 | ||
164 | /** | 178 | /** |
165 | * Allow user to specify log file name (-l option) | 179 | * Allow user to specify log file name (-l option) |
166 | * | 180 | * |
167 | * @param logfn set to the name of the logfile | 181 | * @param[out] logfn set to the name of the logfile |
168 | */ | 182 | */ |
169 | #define GNUNET_GETOPT_OPTION_LOGFILE(logfn) \ | 183 | struct GNUNET_GETOPT_CommandLineOption |
170 | { 'l', "logfile", "LOGFILE", gettext_noop("configure logging to write logs to LOGFILE"), 1, &GNUNET_GETOPT_set_string, (void *) logfn } | 184 | GNUNET_GETOPT_OPTION_LOGFILE (char **logfn); |
171 | 185 | ||
172 | 186 | ||
173 | /** | 187 | /** |
174 | * Allow user to specify log level (-L option) | 188 | * Allow user to specify a string. |
175 | * | 189 | * |
176 | * @param loglev set to the log level | 190 | * @param shortName short name of the option |
191 | * @param name long name of the option | ||
192 | * @param argumentHelp help text for the option argument | ||
193 | * @param description long help text for the option | ||
194 | * @param[out] str set to the string | ||
177 | */ | 195 | */ |
178 | #define GNUNET_GETOPT_OPTION_LOGLEVEL(loglev) \ | 196 | struct GNUNET_GETOPT_CommandLineOption |
179 | { 'L', "log", "LOGLEVEL", gettext_noop("configure logging to use LOGLEVEL"), 1, &GNUNET_GETOPT_set_string, (void *) loglev } | 197 | GNUNET_GETOPT_OPTION_STRING (char shortName, |
198 | const char *name, | ||
199 | const char *argumentHelp, | ||
200 | const char *description, | ||
201 | char **str); | ||
202 | |||
203 | /** | ||
204 | * Allow user to specify a filename (automatically path expanded). | ||
205 | * | ||
206 | * @param shortName short name of the option | ||
207 | * @param name long name of the option | ||
208 | * @param argumentHelp help text for the option argument | ||
209 | * @param description long help text for the option | ||
210 | * @param[out] str set to the string | ||
211 | */ | ||
212 | struct GNUNET_GETOPT_CommandLineOption | ||
213 | GNUNET_GETOPT_OPTION_FILENAME (char shortName, | ||
214 | const char *name, | ||
215 | const char *argumentHelp, | ||
216 | const char *description, | ||
217 | char **str); | ||
180 | 218 | ||
181 | 219 | ||
182 | /** | 220 | /** |
183 | * Get number of verbose (-V) flags | 221 | * Allow user to specify a binary value using Crockford |
222 | * Base32 encoding. | ||
184 | * | 223 | * |
185 | * @param level where to store the verbosity level (should be an 'int') | 224 | * @param shortName short name of the option |
225 | * @param name long name of the option | ||
226 | * @param argumentHelp help text for the option argument | ||
227 | * @param description long help text for the option | ||
228 | * @param[out] val binary value decoded from Crockford Base32-encoded argument | ||
229 | * @param val_size size of @a val in bytes | ||
186 | */ | 230 | */ |
187 | #define GNUNET_GETOPT_OPTION_VERBOSE(level) \ | 231 | struct GNUNET_GETOPT_CommandLineOption |
188 | { 'V', "verbose", (const char *) NULL, gettext_noop("be verbose"), 0, &GNUNET_GETOPT_increment_value, (void *) level } | 232 | GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName, |
233 | const char *name, | ||
234 | const char *argumentHelp, | ||
235 | const char *description, | ||
236 | void *val, | ||
237 | size_t val_size); | ||
189 | 238 | ||
190 | 239 | ||
191 | /** | 240 | /** |
192 | * Get configuration file name (-c option) | 241 | * Allow user to specify a binary value using Crockford |
242 | * Base32 encoding where the size of the binary value is | ||
243 | * automatically determined from its type. | ||
193 | * | 244 | * |
194 | * @param fn set to the configuration file name | 245 | * @param shortName short name of the option |
246 | * @param name long name of the option | ||
247 | * @param argumentHelp help text for the option argument | ||
248 | * @param description long help text for the option | ||
249 | * @param[out] val binary value decoded from Crockford Base32-encoded argument; | ||
250 | * size is determined by type (sizeof (*val)). | ||
195 | */ | 251 | */ |
196 | #define GNUNET_GETOPT_OPTION_CFG_FILE(fn) \ | 252 | #define GNUNET_GETOPT_OPTION_SET_BASE32_AUTO(shortName,name,argumentHelp,description,val) \ |
197 | { 'c', "config", "FILENAME", gettext_noop("use configuration file FILENAME"), 1, &GNUNET_GETOPT_set_string, (void *) fn } | 253 | GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE(shortName,name,argumentHelp,description,val,sizeof(*val)) |
198 | 254 | ||
199 | 255 | ||
200 | /** | 256 | /** |
201 | * Marker for the end of the list of options. | 257 | * Allow user to specify a flag (which internally means setting |
258 | * an integer to 1/#GNUNET_YES/#GNUNET_OK. | ||
259 | * | ||
260 | * @param shortName short name of the option | ||
261 | * @param name long name of the option | ||
262 | * @param description long help text for the option | ||
263 | * @param[out] val set to 1 if the option is present | ||
202 | */ | 264 | */ |
203 | #define GNUNET_GETOPT_OPTION_END \ | 265 | struct GNUNET_GETOPT_CommandLineOption |
204 | { '\0', NULL, NULL, NULL, 0, NULL, NULL } | 266 | GNUNET_GETOPT_OPTION_SET_ONE (char shortName, |
267 | const char *name, | ||
268 | const char *description, | ||
269 | int *val); | ||
205 | 270 | ||
206 | 271 | ||
207 | /** | 272 | /** |
208 | * Parse the command line. | 273 | * Allow user to specify an `unsigned int`. |
209 | * | 274 | * |
210 | * @param binaryOptions Name of application with option summary | 275 | * @param shortName short name of the option |
211 | * @param allOptions defined options and handlers | 276 | * @param name long name of the option |
212 | * @param argc number of arguments in @a argv | 277 | * @param argumentHelp help text for the option argument |
213 | * @param argv actual arguments | 278 | * @param description long help text for the option |
214 | * @return index into argv with first non-option | 279 | * @param[out] val set to the value specified at the command line |
215 | * argument, or #GNUNET_SYSERR on error | ||
216 | */ | 280 | */ |
217 | int | 281 | struct GNUNET_GETOPT_CommandLineOption |
218 | GNUNET_GETOPT_run (const char *binaryOptions, | 282 | GNUNET_GETOPT_OPTION_SET_UINT (char shortName, |
219 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, | 283 | const char *name, |
220 | unsigned int argc, char *const *argv); | 284 | const char *argumentHelp, |
285 | const char *description, | ||
286 | unsigned int *val); | ||
221 | 287 | ||
222 | 288 | ||
223 | /** | 289 | /** |
224 | * Set an option of type 'unsigned long long' from the command line. | 290 | * Allow user to specify an `unsigned long long`. |
225 | * A pointer to this function should be passed as part of the | ||
226 | * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options | ||
227 | * of this type. It should be followed by a pointer to a value of | ||
228 | * type `unsigned long long`. | ||
229 | * | 291 | * |
230 | * @param ctx command line processing context | 292 | * @param shortName short name of the option |
231 | * @param scls additional closure (will point to the 'unsigned long long') | 293 | * @param name long name of the option |
232 | * @param option name of the option | 294 | * @param argumentHelp help text for the option argument |
233 | * @param value actual value of the option as a string. | 295 | * @param description long help text for the option |
234 | * @return #GNUNET_OK if parsing the value worked | 296 | * @param[out] val set to the value specified at the command line |
235 | */ | 297 | */ |
236 | int | 298 | struct GNUNET_GETOPT_CommandLineOption |
237 | GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 299 | GNUNET_GETOPT_OPTION_SET_ULONG (char shortName, |
238 | void *scls, const char *option, const char *value); | 300 | const char *name, |
301 | const char *argumentHelp, | ||
302 | const char *description, | ||
303 | unsigned long long *val); | ||
239 | 304 | ||
240 | 305 | ||
241 | /** | 306 | /** |
242 | * Set an option of type 'struct GNUNET_TIME_Relative' from the command line. | 307 | * Allow user to specify a `struct GNUNET_TIME_Relative` |
243 | * A pointer to this function should be passed as part of the | 308 | * (using human-readable "fancy" time). |
244 | * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options | ||
245 | * of this type. It should be followed by a pointer to a value of | ||
246 | * type `struct GNUNET_TIME_Relative`. | ||
247 | * | 309 | * |
248 | * @param ctx command line processing context | 310 | * @param shortName short name of the option |
249 | * @param scls additional closure (will point to the 'struct GNUNET_TIME_Relative') | 311 | * @param name long name of the option |
250 | * @param option name of the option | 312 | * @param argumentHelp help text for the option argument |
251 | * @param value actual value of the option as a string. | 313 | * @param description long help text for the option |
252 | * @return #GNUNET_OK if parsing the value worked | 314 | * @param[out] val set to the time specified at the command line |
253 | */ | 315 | */ |
254 | int | 316 | struct GNUNET_GETOPT_CommandLineOption |
255 | GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 317 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName, |
256 | void *scls, const char *option, const char *value); | 318 | const char *name, |
319 | const char *argumentHelp, | ||
320 | const char *description, | ||
321 | struct GNUNET_TIME_Relative *val); | ||
257 | 322 | ||
258 | 323 | ||
259 | /** | 324 | /** |
260 | * Set an option of type 'unsigned int' from the command line. | 325 | * Allow user to specify a `struct GNUNET_TIME_Absolute` |
261 | * A pointer to this function should be passed as part of the | 326 | * (using human-readable "fancy" time). |
262 | * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options | ||
263 | * of this type. It should be followed by a pointer to a value of | ||
264 | * type `unsigned int`. | ||
265 | * | 327 | * |
266 | * @param ctx command line processing context | 328 | * @param shortName short name of the option |
267 | * @param scls additional closure (will point to the 'unsigned int') | 329 | * @param name long name of the option |
268 | * @param option name of the option | 330 | * @param argumentHelp help text for the option argument |
269 | * @param value actual value of the option as a string. | 331 | * @param description long help text for the option |
270 | * @return #GNUNET_OK if parsing the value worked | 332 | * @param[out] val set to the time specified at the command line |
271 | */ | 333 | */ |
272 | int | 334 | struct GNUNET_GETOPT_CommandLineOption |
273 | GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 335 | GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName, |
274 | void *scls, const char *option, const char *value); | 336 | const char *name, |
337 | const char *argumentHelp, | ||
338 | const char *description, | ||
339 | struct GNUNET_TIME_Absolute *val); | ||
275 | 340 | ||
276 | 341 | ||
277 | /** | 342 | /** |
278 | * Set an option of type 'int' from the command line to 1 if the | 343 | * Increment @a val each time the option flag is given by one. |
279 | * given option is present. | ||
280 | * A pointer to this function should be passed as part of the | ||
281 | * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options | ||
282 | * of this type. It should be followed by a pointer to a value of | ||
283 | * type `int`. | ||
284 | * | 344 | * |
285 | * @param ctx command line processing context | 345 | * @param shortName short name of the option |
286 | * @param scls additional closure (will point to the `int`) | 346 | * @param name long name of the option |
287 | * @param option name of the option | 347 | * @param argumentHelp help text for the option argument |
288 | * @param value not used (NULL) | 348 | * @param description long help text for the option |
289 | * @return #GNUNET_OK (always) | 349 | * @param[out] val set to 1 if the option is present |
290 | */ | 350 | */ |
291 | int | 351 | struct GNUNET_GETOPT_CommandLineOption |
292 | GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 352 | GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName, |
293 | void *scls, const char *option, const char *value); | 353 | const char *name, |
354 | const char *description, | ||
355 | unsigned int *val); | ||
294 | 356 | ||
295 | 357 | ||
296 | /** | 358 | /** |
297 | * Set an option of type 'char *' from the command line. | 359 | * Define the '-L' log level option. Note that we do not check |
298 | * A pointer to this function should be passed as part of the | 360 | * that the log level is valid here. |
299 | * `struct GNUNET_GETOPT_CommandLineOption` array to initialize options | ||
300 | * of this type. It should be followed by a pointer to a value of | ||
301 | * type `char *`, which will be allocated with the requested string. | ||
302 | * | 361 | * |
303 | * @param ctx command line processing context | 362 | * @param[out] level set to the log level |
304 | * @param scls additional closure (will point to the `char *`, | ||
305 | * which will be allocated) | ||
306 | * @param option name of the option | ||
307 | * @param value actual value of the option (a string) | ||
308 | * @return #GNUNET_OK (always) | ||
309 | */ | 363 | */ |
310 | int | 364 | struct GNUNET_GETOPT_CommandLineOption |
311 | GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 365 | GNUNET_GETOPT_OPTION_LOGLEVEL (char **level); |
312 | void *scls, const char *option, const char *value); | ||
313 | 366 | ||
314 | 367 | ||
315 | /** | 368 | /** |
316 | * Set an option of type 'char *' from the command line doing fs expansion. | 369 | * Define the '-V' verbosity option. Using the option more |
317 | * A pointer to this function should be passed as part of the | 370 | * than once increments @a level each time. |
318 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | ||
319 | * of this type. It should be followed by a pointer to a value of | ||
320 | * type 'char *', which will be allocated with the requested string. | ||
321 | * | 371 | * |
322 | * @param ctx command line processing context | 372 | * @param[out] level set to the verbosity level |
323 | * @param scls additional closure (will point to the 'char *', | ||
324 | * which will be allocated) | ||
325 | * @param option name of the option | ||
326 | * @param value actual value of the option (a string) | ||
327 | * @return #GNUNET_OK (always) | ||
328 | */ | 373 | */ |
329 | int | 374 | struct GNUNET_GETOPT_CommandLineOption |
330 | GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 375 | GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level); |
331 | void *scls, const char *option, const char *value); | 376 | |
332 | 377 | ||
333 | /** | 378 | /** |
334 | * Set an option of type 'unsigned int' from the command line. Each | 379 | * Allow user to specify log file name (-l option) |
335 | * time the option flag is given, the value is incremented by one. | ||
336 | * A pointer to this function should be passed as part of the | ||
337 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | ||
338 | * of this type. It should be followed by a pointer to a value of | ||
339 | * type 'int'. | ||
340 | * | 380 | * |
341 | * @param ctx command line processing context | 381 | * @param[out] logfn set to the name of the logfile |
342 | * @param scls additional closure (will point to the 'int') | ||
343 | * @param option name of the option | ||
344 | * @param value not used (NULL) | ||
345 | * @return #GNUNET_OK (always) | ||
346 | */ | 382 | */ |
347 | int | 383 | struct GNUNET_GETOPT_CommandLineOption |
348 | GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext | 384 | GNUNET_GETOPT_OPTION_LOGFILE (char **logfn); |
349 | *ctx, void *scls, const char *option, | ||
350 | const char *value); | ||
351 | 385 | ||
352 | 386 | ||
353 | /* *************** internal prototypes - use macros above! ************* */ | 387 | /** |
388 | * Allow user to specify configuration file name (-c option) | ||
389 | * | ||
390 | * @param[out] fn set to the name of the configuration file | ||
391 | */ | ||
392 | struct GNUNET_GETOPT_CommandLineOption | ||
393 | GNUNET_GETOPT_OPTION_CFG_FILE (char **fn); | ||
394 | |||
354 | 395 | ||
355 | /** | 396 | /** |
356 | * Print out details on command line options (implements --help). | 397 | * Make the given option mandatory. |
357 | * | 398 | * |
358 | * @param ctx command line processing context | 399 | * @param opt option to modify |
359 | * @param scls additional closure (points to about text) | 400 | * @return @a opt with the mandatory flag set. |
360 | * @param option name of the option | ||
361 | * @param value not used (NULL) | ||
362 | * @return #GNUNET_NO (do not continue, not an error) | ||
363 | */ | 401 | */ |
364 | int | 402 | struct GNUNET_GETOPT_CommandLineOption |
365 | GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext | 403 | GNUNET_GETOPT_OPTION_MANDATORY (struct GNUNET_GETOPT_CommandLineOption opt); |
366 | *ctx, void *scls, const char *option, | 404 | |
367 | const char *value); | ||
368 | 405 | ||
369 | /** | 406 | /** |
370 | * Print out program version (implements --version). | 407 | * Marker for the end of the list of options. |
408 | */ | ||
409 | #define GNUNET_GETOPT_OPTION_END \ | ||
410 | { '\0', NULL, NULL, NULL, 0, 0, NULL, NULL, NULL } | ||
411 | |||
412 | |||
413 | /** | ||
414 | * Parse the command line. | ||
371 | * | 415 | * |
372 | * @param ctx command line processing context | 416 | * @param binaryOptions Name of application with option summary |
373 | * @param scls additional closure (points to version string) | 417 | * @param allOptions defined options and handlers |
374 | * @param option name of the option | 418 | * @param argc number of arguments in @a argv |
375 | * @param value not used (NULL) | 419 | * @param argv actual arguments |
376 | * @return #GNUNET_NO (do not continue, not an error) | 420 | * @return index into argv with first non-option |
421 | * argument, or #GNUNET_SYSERR on error | ||
377 | */ | 422 | */ |
378 | int | 423 | int |
379 | GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext | 424 | GNUNET_GETOPT_run (const char *binaryOptions, |
380 | *ctx, void *scls, const char *option, | 425 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, |
381 | const char *value); | 426 | unsigned int argc, |
427 | char *const *argv); | ||
428 | |||
382 | 429 | ||
383 | #if 0 /* keep Emacsens' auto-indent happy */ | 430 | #if 0 /* keep Emacsens' auto-indent happy */ |
384 | { | 431 | { |
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 9e5f9e284..ce721d8d8 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h | |||
@@ -427,6 +427,26 @@ void | |||
427 | GNUNET_JSON_post_parser_cleanup (void *con_cls); | 427 | GNUNET_JSON_post_parser_cleanup (void *con_cls); |
428 | 428 | ||
429 | 429 | ||
430 | /* ****************** GETOPT JSON helper ******************* */ | ||
431 | |||
432 | |||
433 | /** | ||
434 | * Allow user to specify a JSON input value. | ||
435 | * | ||
436 | * @param shortName short name of the option | ||
437 | * @param name long name of the option | ||
438 | * @param argumentHelp help text for the option argument | ||
439 | * @param description long help text for the option | ||
440 | * @param[out] val set to the JSON specified at the command line | ||
441 | */ | ||
442 | struct GNUNET_GETOPT_CommandLineOption | ||
443 | GNUNET_JSON_getopt (char shortName, | ||
444 | const char *name, | ||
445 | const char *argumentHelp, | ||
446 | const char *description, | ||
447 | json_t **json); | ||
448 | |||
449 | |||
430 | #endif | 450 | #endif |
431 | 451 | ||
432 | /* end of gnunet_json_lib.h */ | 452 | /* end of gnunet_json_lib.h */ |
diff --git a/src/json/json.c b/src/json/json.c index a2d1a9608..c182a02f4 100644 --- a/src/json/json.c +++ b/src/json/json.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2014, 2015, 2016 GNUnet e.V. | 3 | Copyright (C) 2014-2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify it under the | 5 | GNUnet is free software; you can redistribute it and/or modify it under the |
6 | terms of the GNU General Public License as published by the Free Software | 6 | terms of the GNU General Public License as published by the Free Software |
@@ -82,13 +82,78 @@ GNUNET_JSON_parse (const json_t *root, | |||
82 | void | 82 | void |
83 | GNUNET_JSON_parse_free (struct GNUNET_JSON_Specification *spec) | 83 | GNUNET_JSON_parse_free (struct GNUNET_JSON_Specification *spec) |
84 | { | 84 | { |
85 | unsigned int i; | 85 | for (unsigned int i=0;NULL != spec[i].parser;i++) |
86 | |||
87 | for (i=0;NULL != spec[i].parser;i++) | ||
88 | if (NULL != spec[i].cleaner) | 86 | if (NULL != spec[i].cleaner) |
89 | spec[i].cleaner (spec[i].cls, | 87 | spec[i].cleaner (spec[i].cls, |
90 | &spec[i]); | 88 | &spec[i]); |
91 | } | 89 | } |
92 | 90 | ||
93 | 91 | ||
92 | /** | ||
93 | * Set an option with a JSON value from the command line. | ||
94 | * A pointer to this function should be passed as part of the | ||
95 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | ||
96 | * of this type. | ||
97 | * | ||
98 | * @param ctx command line processing context | ||
99 | * @param scls additional closure (will point to the 'json_t *') | ||
100 | * @param option name of the option | ||
101 | * @param value actual value of the option as a string. | ||
102 | * @return #GNUNET_OK if parsing the value worked | ||
103 | */ | ||
104 | static int | ||
105 | set_json (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | ||
106 | void *scls, | ||
107 | const char *option, | ||
108 | const char *value) | ||
109 | { | ||
110 | json_t **json = scls; | ||
111 | json_error_t error; | ||
112 | |||
113 | *json = json_loads (value, | ||
114 | JSON_REJECT_DUPLICATES, | ||
115 | &error); | ||
116 | if (NULL == *json) | ||
117 | { | ||
118 | FPRINTF (stderr, | ||
119 | _("Failed to parse JSON in option `%s': %s (%s)\n"), | ||
120 | option, | ||
121 | error.text, | ||
122 | error.source); | ||
123 | return GNUNET_SYSERR; | ||
124 | } | ||
125 | return GNUNET_OK; | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Allow user to specify a JSON input value. | ||
131 | * | ||
132 | * @param shortName short name of the option | ||
133 | * @param name long name of the option | ||
134 | * @param argumentHelp help text for the option argument | ||
135 | * @param description long help text for the option | ||
136 | * @param[out] val set to the JSON specified at the command line | ||
137 | */ | ||
138 | struct GNUNET_GETOPT_CommandLineOption | ||
139 | GNUNET_JSON_getopt (char shortName, | ||
140 | const char *name, | ||
141 | const char *argumentHelp, | ||
142 | const char *description, | ||
143 | json_t **json) | ||
144 | { | ||
145 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
146 | .shortName = shortName, | ||
147 | .name = name, | ||
148 | .argumentHelp = argumentHelp, | ||
149 | .description = description, | ||
150 | .require_argument = 1, | ||
151 | .processor = &set_json, | ||
152 | .scls = (void *) json | ||
153 | }; | ||
154 | |||
155 | return clo; | ||
156 | } | ||
157 | |||
158 | |||
94 | /* end of json.c */ | 159 | /* end of json.c */ |
diff --git a/src/namecache/gnunet-namecache.c b/src/namecache/gnunet-namecache.c index 490197b1e..2410c9b3c 100644 --- a/src/namecache/gnunet-namecache.c +++ b/src/namecache/gnunet-namecache.c | |||
@@ -225,13 +225,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
225 | int | 225 | int |
226 | main (int argc, char *const *argv) | 226 | main (int argc, char *const *argv) |
227 | { | 227 | { |
228 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 228 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
229 | {'n', "name", "NAME", | 229 | GNUNET_GETOPT_OPTION_STRING ('n', |
230 | gettext_noop ("name of the record to add/delete/display"), 1, | 230 | "name", |
231 | &GNUNET_GETOPT_set_string, &name}, | 231 | "NAME", |
232 | {'z', "zone", "PKEY", | 232 | gettext_noop ("name of the record to add/delete/display"), |
233 | gettext_noop ("spezifies the public key of the zone to look in"), 1, | 233 | &name), |
234 | &GNUNET_GETOPT_set_string, &pkey}, | 234 | |
235 | GNUNET_GETOPT_OPTION_STRING ('z', | ||
236 | "zone", | ||
237 | "PKEY", | ||
238 | gettext_noop ("spezifies the public key of the zone to look in"), | ||
239 | &pkey), | ||
240 | |||
235 | GNUNET_GETOPT_OPTION_END | 241 | GNUNET_GETOPT_OPTION_END |
236 | }; | 242 | }; |
237 | 243 | ||
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 457e77022..2ce3741f8 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1130,49 +1130,88 @@ main (int argc, | |||
1130 | is_public = -1; | 1130 | is_public = -1; |
1131 | is_shadow = -1; | 1131 | is_shadow = -1; |
1132 | 1132 | ||
1133 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1133 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1134 | {'a', "add", NULL, | 1134 | |
1135 | gettext_noop ("add record"), 0, | 1135 | GNUNET_GETOPT_OPTION_SET_ONE ('a', |
1136 | &GNUNET_GETOPT_set_one, &add}, | 1136 | "add", |
1137 | {'d', "delete", NULL, | 1137 | gettext_noop ("add record"), |
1138 | gettext_noop ("delete record"), 0, | 1138 | &add), |
1139 | &GNUNET_GETOPT_set_one, &del}, | 1139 | |
1140 | {'D', "display", NULL, | 1140 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
1141 | gettext_noop ("display records"), 0, | 1141 | "delete", |
1142 | &GNUNET_GETOPT_set_one, &list}, | 1142 | gettext_noop ("delete record"), |
1143 | {'e', "expiration", "TIME", | 1143 | &del), |
1144 | gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1, | 1144 | |
1145 | &GNUNET_GETOPT_set_string, &expirationstring}, | 1145 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
1146 | {'i', "nick", "NICKNAME", | 1146 | "display", |
1147 | gettext_noop ("set the desired nick name for the zone"), 1, | 1147 | gettext_noop ("display records"), |
1148 | &GNUNET_GETOPT_set_string, &nickstring}, | 1148 | &list), |
1149 | {'m', "monitor", NULL, | 1149 | |
1150 | gettext_noop ("monitor changes in the namestore"), 0, | 1150 | GNUNET_GETOPT_OPTION_STRING ('e', |
1151 | &GNUNET_GETOPT_set_one, &monitor}, | 1151 | "expiration", |
1152 | {'n', "name", "NAME", | 1152 | "TIME", |
1153 | gettext_noop ("name of the record to add/delete/display"), 1, | 1153 | gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), |
1154 | &GNUNET_GETOPT_set_string, &name}, | 1154 | &expirationstring), |
1155 | {'r', "reverse", "PKEY", | 1155 | |
1156 | gettext_noop ("determine our name for the given PKEY"), 1, | 1156 | GNUNET_GETOPT_OPTION_STRING ('i', |
1157 | &GNUNET_GETOPT_set_string, &reverse_pkey}, | 1157 | "nick", |
1158 | {'t', "type", "TYPE", | 1158 | "NICKNAME", |
1159 | gettext_noop ("type of the record to add/delete/display"), 1, | 1159 | gettext_noop ("set the desired nick name for the zone"), |
1160 | &GNUNET_GETOPT_set_string, &typestring}, | 1160 | &nickstring), |
1161 | {'u', "uri", "URI", | 1161 | |
1162 | gettext_noop ("URI to import into our zone"), 1, | 1162 | GNUNET_GETOPT_OPTION_SET_ONE ('m', |
1163 | &GNUNET_GETOPT_set_string, &uri}, | 1163 | "monitor", |
1164 | {'V', "value", "VALUE", | 1164 | gettext_noop ("monitor changes in the namestore"), |
1165 | gettext_noop ("value of the record to add/delete"), 1, | 1165 | &monitor), |
1166 | &GNUNET_GETOPT_set_string, &value}, | 1166 | |
1167 | {'p', "public", NULL, | 1167 | GNUNET_GETOPT_OPTION_STRING ('n', |
1168 | gettext_noop ("create or list public record"), 0, | 1168 | "name", |
1169 | &GNUNET_GETOPT_set_one, &is_public}, | 1169 | "NAME", |
1170 | {'s', "shadow", NULL, | 1170 | gettext_noop ("name of the record to add/delete/display"), |
1171 | gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), 0, | 1171 | &name), |
1172 | &GNUNET_GETOPT_set_one, &is_shadow}, | 1172 | |
1173 | {'z', "zone", "EGO", | 1173 | GNUNET_GETOPT_OPTION_STRING ('r', |
1174 | gettext_noop ("name of the ego controlling the zone"), 1, | 1174 | "reverse", |
1175 | &GNUNET_GETOPT_set_string, &ego_name}, | 1175 | "PKEY", |
1176 | gettext_noop ("determine our name for the given PKEY"), | ||
1177 | &reverse_pkey), | ||
1178 | |||
1179 | |||
1180 | |||
1181 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
1182 | "type", | ||
1183 | "TYPE", | ||
1184 | gettext_noop ("type of the record to add/delete/display"), | ||
1185 | &typestring), | ||
1186 | |||
1187 | GNUNET_GETOPT_OPTION_STRING ('u', | ||
1188 | "uri", | ||
1189 | "URI", | ||
1190 | gettext_noop ("URI to import into our zone"), | ||
1191 | &uri), | ||
1192 | |||
1193 | GNUNET_GETOPT_OPTION_STRING ('V', | ||
1194 | "value", | ||
1195 | "VALUE", | ||
1196 | gettext_noop ("value of the record to add/delete"), | ||
1197 | &value), | ||
1198 | |||
1199 | GNUNET_GETOPT_OPTION_SET_ONE ('p', | ||
1200 | "public", | ||
1201 | gettext_noop ("create or list public record"), | ||
1202 | &is_public), | ||
1203 | |||
1204 | GNUNET_GETOPT_OPTION_SET_ONE ('s', | ||
1205 | "shadow", | ||
1206 | gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), | ||
1207 | &is_shadow), | ||
1208 | |||
1209 | GNUNET_GETOPT_OPTION_STRING ('z', | ||
1210 | "zone", | ||
1211 | "EGO", | ||
1212 | gettext_noop ("name of the ego controlling the zone"), | ||
1213 | &ego_name), | ||
1214 | |||
1176 | GNUNET_GETOPT_OPTION_END | 1215 | GNUNET_GETOPT_OPTION_END |
1177 | }; | 1216 | }; |
1178 | 1217 | ||
diff --git a/src/nat-auto/gnunet-nat-auto.c b/src/nat-auto/gnunet-nat-auto.c index 5eb0a4be3..8b281d1ab 100644 --- a/src/nat-auto/gnunet-nat-auto.c +++ b/src/nat-auto/gnunet-nat-auto.c | |||
@@ -63,7 +63,7 @@ static char *section_name; | |||
63 | /** | 63 | /** |
64 | * Should we run autoconfiguration? | 64 | * Should we run autoconfiguration? |
65 | */ | 65 | */ |
66 | static unsigned int do_auto; | 66 | static int do_auto; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Handle to a NAT test operation. | 69 | * Handle to a NAT test operation. |
@@ -339,22 +339,32 @@ int | |||
339 | main (int argc, | 339 | main (int argc, |
340 | char *const argv[]) | 340 | char *const argv[]) |
341 | { | 341 | { |
342 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 342 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
343 | {'a', "auto", NULL, | 343 | GNUNET_GETOPT_OPTION_SET_ONE ('a', |
344 | gettext_noop ("run autoconfiguration"), | 344 | "auto", |
345 | GNUNET_NO, &GNUNET_GETOPT_set_one, &do_auto }, | 345 | gettext_noop ("run autoconfiguration"), |
346 | {'S', "section", "NAME", | 346 | &do_auto), |
347 | gettext_noop ("section name providing the configuration for the adapter"), | 347 | |
348 | GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name }, | 348 | GNUNET_GETOPT_OPTION_STRING ('S', |
349 | {'t', "tcp", NULL, | 349 | "section", |
350 | gettext_noop ("use TCP"), | 350 | "NAME", |
351 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp }, | 351 | gettext_noop ("section name providing the configuration for the adapter"), |
352 | {'u', "udp", NULL, | 352 | §ion_name), |
353 | gettext_noop ("use UDP"), | 353 | |
354 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_udp }, | 354 | GNUNET_GETOPT_OPTION_SET_ONE ('t', |
355 | {'w', "write", NULL, | 355 | "tcp", |
356 | gettext_noop ("write configuration file (for autoconfiguration)"), | 356 | gettext_noop ("use TCP"), |
357 | GNUNET_NO, &GNUNET_GETOPT_set_one, &write_cfg }, | 357 | &use_tcp), |
358 | |||
359 | GNUNET_GETOPT_OPTION_SET_ONE ('u', | ||
360 | "udp", | ||
361 | gettext_noop ("use UDP"), | ||
362 | &use_udp), | ||
363 | |||
364 | GNUNET_GETOPT_OPTION_SET_ONE ('w', | ||
365 | "write", | ||
366 | gettext_noop ("write configuration file (for autoconfiguration)"), | ||
367 | &write_cfg), | ||
358 | GNUNET_GETOPT_OPTION_END | 368 | GNUNET_GETOPT_OPTION_END |
359 | }; | 369 | }; |
360 | 370 | ||
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index 04bde5111..50e0dff0f 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -72,7 +72,7 @@ static char *remote_addr; | |||
72 | /** | 72 | /** |
73 | * Should we actually bind to #bind_addr and receive and process STUN requests? | 73 | * Should we actually bind to #bind_addr and receive and process STUN requests? |
74 | */ | 74 | */ |
75 | static unsigned int do_stun; | 75 | static int do_stun; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Handle to NAT operation. | 78 | * Handle to NAT operation. |
@@ -417,29 +417,46 @@ int | |||
417 | main (int argc, | 417 | main (int argc, |
418 | char *const argv[]) | 418 | char *const argv[]) |
419 | { | 419 | { |
420 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 420 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
421 | {'i', "in", "ADDRESS", | 421 | |
422 | gettext_noop ("which IP and port are we locally using to bind/listen to"), | 422 | GNUNET_GETOPT_OPTION_STRING ('i', |
423 | GNUNET_YES, &GNUNET_GETOPT_set_string, &local_addr }, | 423 | "in", |
424 | {'r', "remote", "ADDRESS", | 424 | "ADDRESS", |
425 | gettext_noop ("which remote IP and port should be asked for connection reversal"), | 425 | gettext_noop ("which IP and port are we locally using to bind/listen to"), |
426 | GNUNET_YES, &GNUNET_GETOPT_set_string, &remote_addr }, | 426 | &local_addr), |
427 | {'S', "section", NULL, | 427 | |
428 | gettext_noop ("name of configuration section to find additional options, such as manual host punching data"), | 428 | GNUNET_GETOPT_OPTION_STRING ('r', |
429 | GNUNET_YES, &GNUNET_GETOPT_set_string, §ion_name }, | 429 | "remote", |
430 | {'s', "stun", NULL, | 430 | "ADDRESS", |
431 | gettext_noop ("enable STUN processing"), | 431 | gettext_noop ("which remote IP and port should be asked for connection reversal"), |
432 | GNUNET_NO, &GNUNET_GETOPT_set_one, &do_stun }, | 432 | &remote_addr), |
433 | {'t', "tcp", NULL, | 433 | |
434 | gettext_noop ("use TCP"), | 434 | GNUNET_GETOPT_OPTION_STRING ('S', |
435 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp }, | 435 | "section", |
436 | {'u', "udp", NULL, | 436 | NULL, |
437 | gettext_noop ("use UDP"), | 437 | gettext_noop ("name of configuration section to find additional options, such as manual host punching data"), |
438 | GNUNET_NO, &GNUNET_GETOPT_set_one, &use_udp }, | 438 | §ion_name), |
439 | {'W', "watch", NULL, | 439 | |
440 | gettext_noop ("watch for connection reversal requests"), | 440 | GNUNET_GETOPT_OPTION_SET_ONE ('s', |
441 | GNUNET_NO, &GNUNET_GETOPT_set_one, &listen_reversal }, | 441 | "stun", |
442 | GNUNET_GETOPT_OPTION_END | 442 | gettext_noop ("enable STUN processing"), |
443 | &do_stun), | ||
444 | |||
445 | GNUNET_GETOPT_OPTION_SET_ONE ('t', | ||
446 | "tcp", | ||
447 | gettext_noop ("use TCP"), | ||
448 | &use_tcp), | ||
449 | |||
450 | GNUNET_GETOPT_OPTION_SET_ONE ('u', | ||
451 | "udp", | ||
452 | gettext_noop ("use UDP"), | ||
453 | &use_udp), | ||
454 | |||
455 | GNUNET_GETOPT_OPTION_SET_ONE ('W', | ||
456 | "watch", | ||
457 | gettext_noop ("watch for connection reversal requests"), | ||
458 | &listen_reversal), | ||
459 | GNUNET_GETOPT_OPTION_END | ||
443 | }; | 460 | }; |
444 | 461 | ||
445 | if (GNUNET_OK != | 462 | if (GNUNET_OK != |
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 48afd9298..ea28bf610 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -129,7 +129,7 @@ static int ok; | |||
129 | /** | 129 | /** |
130 | * Be verbose (configuration option) | 130 | * Be verbose (configuration option) |
131 | */ | 131 | */ |
132 | static int verbose; | 132 | static unsigned int verbose; |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * Name of the file with the hosts to run the test over (configuration option) | 135 | * Name of the file with the hosts to run the test over (configuration option) |
@@ -835,28 +835,47 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
835 | int | 835 | int |
836 | main (int argc, char *const *argv) | 836 | main (int argc, char *const *argv) |
837 | { | 837 | { |
838 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 838 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
839 | {'C', "connections", "COUNT", | 839 | GNUNET_GETOPT_OPTION_SET_UINT ('C', |
840 | gettext_noop ("limit to the number of connections to NSE services, 0 for none"), | 840 | "connections", |
841 | 1, &GNUNET_GETOPT_set_uint, &connection_limit}, | 841 | "COUNT", |
842 | {'d', "details", "FILENAME", | 842 | gettext_noop ("limit to the number of connections to NSE services, 0 for none"), |
843 | gettext_noop ("name of the file for writing connection information and statistics"), | 843 | &connection_limit), |
844 | 1, &GNUNET_GETOPT_set_string, &data_filename}, | 844 | GNUNET_GETOPT_OPTION_STRING ('d', |
845 | {'H', "hosts", "FILENAME", | 845 | "details", |
846 | gettext_noop ("name of the file with the login information for the testbed"), | 846 | "FILENAME", |
847 | 1, &GNUNET_GETOPT_set_string, &hosts_file}, | 847 | gettext_noop ("name of the file for writing connection information and statistics"), |
848 | {'o', "output", "FILENAME", | 848 | &data_filename), |
849 | gettext_noop ("name of the file for writing the main results"), | 849 | |
850 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | 850 | GNUNET_GETOPT_OPTION_STRING ('H', |
851 | {'p', "peers", "NETWORKSIZESPEC", | 851 | "hosts", |
852 | gettext_noop ("Number of peers to run in each round, separated by commas"), | 852 | "FILENAME", |
853 | 1, &GNUNET_GETOPT_set_string, &num_peer_spec}, | 853 | gettext_noop ("name of the file with the login information for the testbed"), |
854 | {'V', "verbose", NULL, | 854 | &hosts_file), |
855 | gettext_noop ("be verbose (print progress information)"), | 855 | |
856 | 0, &GNUNET_GETOPT_increment_value, &verbose}, | 856 | GNUNET_GETOPT_OPTION_STRING ('o', |
857 | {'w', "wait", "DELAY", | 857 | "output", |
858 | gettext_noop ("delay between rounds"), | 858 | "FILENAME", |
859 | 1, &GNUNET_GETOPT_set_relative_time, &wait_time}, | 859 | gettext_noop ("name of the file for writing the main results"), |
860 | &output_filename), | ||
861 | |||
862 | |||
863 | GNUNET_GETOPT_OPTION_STRING ('p', | ||
864 | "peers", | ||
865 | "NETWORKSIZESPEC", | ||
866 | gettext_noop ("Number of peers to run in each round, separated by commas"), | ||
867 | &num_peer_spec), | ||
868 | |||
869 | GNUNET_GETOPT_OPTION_INCREMENT_VALUE ('V', | ||
870 | "verbose", | ||
871 | gettext_noop ("be verbose (print progress information)"), | ||
872 | &verbose), | ||
873 | |||
874 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('w', | ||
875 | "wait", | ||
876 | "DELAY", | ||
877 | gettext_noop ("delay between rounds"), | ||
878 | &wait_time), | ||
860 | GNUNET_GETOPT_OPTION_END | 879 | GNUNET_GETOPT_OPTION_END |
861 | }; | 880 | }; |
862 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 881 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index a5907c63f..59ffe2efd 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -837,31 +837,48 @@ state_machine (void *cls) | |||
837 | int | 837 | int |
838 | main (int argc, char *const *argv) | 838 | main (int argc, char *const *argv) |
839 | { | 839 | { |
840 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 840 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
841 | {'n', "numeric", NULL, | 841 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
842 | gettext_noop ("don't resolve host names"), | 842 | "numeric", |
843 | 0, &GNUNET_GETOPT_set_one, &no_resolve}, | 843 | gettext_noop ("don't resolve host names"), |
844 | {'q', "quiet", NULL, | 844 | &no_resolve), |
845 | gettext_noop ("output only the identity strings"), | 845 | |
846 | 0, &GNUNET_GETOPT_set_one, &be_quiet}, | 846 | GNUNET_GETOPT_OPTION_SET_ONE ('q', |
847 | {'f', "friends", NULL, | 847 | "quiet", |
848 | gettext_noop ("include friend-only information"), | 848 | gettext_noop ("output only the identity strings"), |
849 | 0, &GNUNET_GETOPT_set_one, &include_friend_only}, | 849 | &be_quiet), |
850 | {'s', "self", NULL, | 850 | GNUNET_GETOPT_OPTION_SET_ONE ('f', |
851 | gettext_noop ("output our own identity only"), | 851 | "friends", |
852 | 0, &GNUNET_GETOPT_set_one, &get_self}, | 852 | gettext_noop ("include friend-only information"), |
853 | {'i', "info", NULL, | 853 | &include_friend_only), |
854 | gettext_noop ("list all known peers"), | 854 | |
855 | 0, &GNUNET_GETOPT_set_one, &get_info}, | 855 | GNUNET_GETOPT_OPTION_SET_ONE ('s', |
856 | {'d', "dump-hello", NULL, | 856 | "self", |
857 | gettext_noop ("dump hello to file"), | 857 | gettext_noop ("output our own identity only"), |
858 | 1, &GNUNET_GETOPT_set_string, &dump_hello}, | 858 | &get_self), |
859 | {'g', "get-hello", NULL, | 859 | |
860 | gettext_noop ("also output HELLO uri(s)"), | 860 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
861 | 0, &GNUNET_GETOPT_set_one, &get_uri}, | 861 | "info", |
862 | {'p', "put-hello", "HELLO", | 862 | gettext_noop ("list all known peers"), |
863 | gettext_noop ("add given HELLO uri to the database"), | 863 | &get_info), |
864 | 1, &GNUNET_GETOPT_set_string, &put_uri}, | 864 | |
865 | GNUNET_GETOPT_OPTION_STRING ('d', | ||
866 | "dump-hello", | ||
867 | NULL, | ||
868 | gettext_noop ("dump hello to file"), | ||
869 | &dump_hello), | ||
870 | |||
871 | GNUNET_GETOPT_OPTION_SET_ONE ('g', | ||
872 | "get-hello", | ||
873 | gettext_noop ("also output HELLO uri(s)"), | ||
874 | &get_uri), | ||
875 | |||
876 | GNUNET_GETOPT_OPTION_STRING ('p', | ||
877 | "put-hello", | ||
878 | "HELLO", | ||
879 | gettext_noop ("add given HELLO uri to the database"), | ||
880 | &put_uri), | ||
881 | |||
865 | GNUNET_GETOPT_OPTION_END | 882 | GNUNET_GETOPT_OPTION_END |
866 | }; | 883 | }; |
867 | int ret; | 884 | int ret; |
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index dfbcd388a..71f3580f8 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -1477,22 +1477,39 @@ run (void *cls, | |||
1477 | int | 1477 | int |
1478 | main (int argc, char *const *argv) | 1478 | main (int argc, char *const *argv) |
1479 | { | 1479 | { |
1480 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1480 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1481 | {'o', "output-file", "FILENAME", | 1481 | |
1482 | gettext_noop ("name of the file for writing statistics"), | 1482 | GNUNET_GETOPT_OPTION_FILENAME ('o', |
1483 | GNUNET_YES, &GNUNET_GETOPT_set_string, &data_filename}, | 1483 | "output-file", |
1484 | {'t', "matching-timeout", "TIMEOUT", | 1484 | "FILENAME", |
1485 | gettext_noop ("wait TIMEOUT before ending the experiment"), | 1485 | gettext_noop ("name of the file for writing statistics"), |
1486 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &search_timeout_time}, | 1486 | &data_filename), |
1487 | {'p', "policy-dir", "DIRECTORY", | 1487 | |
1488 | gettext_noop ("directory with policy files"), | 1488 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', |
1489 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &policy_dir}, | 1489 | "matching-timeout", |
1490 | {'s', "strings-file", "FILENAME", | 1490 | "TIMEOUT", |
1491 | gettext_noop ("name of file with input strings"), | 1491 | gettext_noop ("wait TIMEOUT before ending the experiment"), |
1492 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file}, | 1492 | &search_timeout_time), |
1493 | {'H', "hosts-file", "FILENAME", | 1493 | |
1494 | gettext_noop ("name of file with hosts' names"), | 1494 | GNUNET_GETOPT_OPTION_FILENAME ('p', |
1495 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &hosts_file}, | 1495 | "policy-dir", |
1496 | "DIRECTORY", | ||
1497 | gettext_noop ("directory with policy files"), | ||
1498 | &policy_dir), | ||
1499 | |||
1500 | |||
1501 | GNUNET_GETOPT_OPTION_FILENAME ('s', | ||
1502 | "strings-file", | ||
1503 | "FILENAME", | ||
1504 | gettext_noop ("name of file with input strings"), | ||
1505 | &strings_file), | ||
1506 | |||
1507 | GNUNET_GETOPT_OPTION_FILENAME ('H', | ||
1508 | "hosts-file", | ||
1509 | "FILENAME", | ||
1510 | gettext_noop ("name of file with hosts' names"), | ||
1511 | &hosts_file), | ||
1512 | |||
1496 | GNUNET_GETOPT_OPTION_END | 1513 | GNUNET_GETOPT_OPTION_END |
1497 | }; | 1514 | }; |
1498 | int ret; | 1515 | int ret; |
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index b115deb20..0b6c18267 100644 --- a/src/rest/gnunet-rest-server.c +++ b/src/rest/gnunet-rest-server.c | |||
@@ -66,7 +66,7 @@ static struct GNUNET_SCHEDULER_Task *httpd_task; | |||
66 | /** | 66 | /** |
67 | * The port the service is running on (default 7776) | 67 | * The port the service is running on (default 7776) |
68 | */ | 68 | */ |
69 | static unsigned long port = GNUNET_REST_SERVICE_PORT; | 69 | static unsigned long long port = GNUNET_REST_SERVICE_PORT; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * The listen socket of the service for IPv4 | 72 | * The listen socket of the service for IPv4 |
@@ -748,7 +748,7 @@ run (void *cls, | |||
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
751 | "Service listens on port %lu\n", | 751 | "Service listens on port %llu\n", |
752 | port); | 752 | port); |
753 | httpd = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_NO_LISTEN_SOCKET, | 753 | httpd = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_NO_LISTEN_SOCKET, |
754 | 0, | 754 | 0, |
@@ -783,10 +783,12 @@ run (void *cls, | |||
783 | int | 783 | int |
784 | main (int argc, char *const *argv) | 784 | main (int argc, char *const *argv) |
785 | { | 785 | { |
786 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 786 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
787 | {'p', "port", NULL, | 787 | GNUNET_GETOPT_OPTION_SET_ULONG ('p', |
788 | gettext_noop ("listen on specified port (default: 7776)"), 1, | 788 | "port", |
789 | &GNUNET_GETOPT_set_ulong, &port}, | 789 | "PORT", |
790 | gettext_noop ("listen on specified port (default: 7776)"), | ||
791 | &port), | ||
790 | GNUNET_GETOPT_OPTION_END | 792 | GNUNET_GETOPT_OPTION_END |
791 | }; | 793 | }; |
792 | static const char* err_page = | 794 | static const char* err_page = |
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index 133468789..7b40c83d7 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -527,19 +527,31 @@ run (void *cls, | |||
527 | int | 527 | int |
528 | main (int argc, char *const *argv) | 528 | main (int argc, char *const *argv) |
529 | { | 529 | { |
530 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 530 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
531 | {'f', "filename", "NAME", | 531 | |
532 | gettext_noop ("use NAME for the name of the revocation file"), | 532 | GNUNET_GETOPT_OPTION_STRING ('f', |
533 | 1, &GNUNET_GETOPT_set_string, &filename}, | 533 | "filename", |
534 | {'R', "revoke", "NAME", | 534 | "NAME", |
535 | gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "), | 535 | gettext_noop ("use NAME for the name of the revocation file"), |
536 | 1, &GNUNET_GETOPT_set_string, &revoke_ego}, | 536 | &filename), |
537 | {'p', "perform", NULL, | 537 | |
538 | gettext_noop ("actually perform revocation, otherwise we just do the precomputation"), | 538 | GNUNET_GETOPT_OPTION_STRING ('R', |
539 | 0, &GNUNET_GETOPT_set_one, &perform}, | 539 | "revoke", |
540 | {'t', "test", "KEY", | 540 | "NAME", |
541 | gettext_noop ("test if the public key KEY has been revoked"), | 541 | gettext_noop ("revoke the private key associated for the the private key associated with the ego NAME "), |
542 | 1, &GNUNET_GETOPT_set_string, &test_ego}, | 542 | &revoke_ego), |
543 | |||
544 | GNUNET_GETOPT_OPTION_SET_ONE ('p', | ||
545 | "perform", | ||
546 | gettext_noop ("actually perform revocation, otherwise we just do the precomputation"), | ||
547 | &perform), | ||
548 | |||
549 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
550 | "test", | ||
551 | "KEY", | ||
552 | gettext_noop ("test if the public key KEY has been revoked"), | ||
553 | &test_ego), | ||
554 | |||
543 | GNUNET_GETOPT_OPTION_END | 555 | GNUNET_GETOPT_OPTION_END |
544 | }; | 556 | }; |
545 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 557 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c index aa894b61d..5d0fce2b1 100644 --- a/src/scalarproduct/gnunet-scalarproduct.c +++ b/src/scalarproduct/gnunet-scalarproduct.c | |||
@@ -343,16 +343,32 @@ run (void *cls, | |||
343 | int | 343 | int |
344 | main (int argc, char *const *argv) | 344 | main (int argc, char *const *argv) |
345 | { | 345 | { |
346 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 346 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
347 | {'e', "elements", "\"key1,val1;key2,val2;...,keyn,valn;\"", | 347 | |
348 | gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."), | 348 | GNUNET_GETOPT_OPTION_STRING ('e', |
349 | 1, &GNUNET_GETOPT_set_string, &input_elements}, | 349 | "elements", |
350 | {'p', "peer", "PEERID", | 350 | "\"key1,val1;key2,val2;...,keyn,valn;\"", |
351 | gettext_noop ("[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."), | 351 | gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."), |
352 | 1, &GNUNET_GETOPT_set_string, &input_peer_id}, | 352 | &input_elements), |
353 | {'k', "key", "TRANSACTION_ID", | 353 | |
354 | gettext_noop ("Transaction ID shared with peer."), | 354 | GNUNET_GETOPT_OPTION_STRING ('e', |
355 | 1, &GNUNET_GETOPT_set_string, &input_session_key}, | 355 | "elements", |
356 | "\"key1,val1;key2,val2;...,keyn,valn;\"", | ||
357 | gettext_noop ("A comma separated list of elements to compare as vector with our remote peer."), | ||
358 | &input_elements), | ||
359 | |||
360 | GNUNET_GETOPT_OPTION_STRING ('p', | ||
361 | "peer", | ||
362 | "PEERID", | ||
363 | gettext_noop ("[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."), | ||
364 | &input_peer_id), | ||
365 | |||
366 | GNUNET_GETOPT_OPTION_STRING ('k', | ||
367 | "key", | ||
368 | "TRANSACTION_ID", | ||
369 | gettext_noop ("Transaction ID shared with peer."), | ||
370 | &input_session_key), | ||
371 | |||
356 | GNUNET_GETOPT_OPTION_END | 372 | GNUNET_GETOPT_OPTION_END |
357 | }; | 373 | }; |
358 | 374 | ||
diff --git a/src/secretsharing/gnunet-secretsharing-profiler.c b/src/secretsharing/gnunet-secretsharing-profiler.c index 3ff5d7fdd..e66019dc6 100644 --- a/src/secretsharing/gnunet-secretsharing-profiler.c +++ b/src/secretsharing/gnunet-secretsharing-profiler.c | |||
@@ -41,7 +41,7 @@ static unsigned int threshold = 2; | |||
41 | /** | 41 | /** |
42 | * Should we try to decrypt a value after the key generation? | 42 | * Should we try to decrypt a value after the key generation? |
43 | */ | 43 | */ |
44 | static unsigned int decrypt = GNUNET_NO; | 44 | static int decrypt = GNUNET_NO; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * When would we like to see the operation finished? | 47 | * When would we like to see the operation finished? |
@@ -88,7 +88,7 @@ static unsigned int num_decrypted; | |||
88 | 88 | ||
89 | static struct GNUNET_HashCode session_id; | 89 | static struct GNUNET_HashCode session_id; |
90 | 90 | ||
91 | static int verbose; | 91 | static unsigned int verbose; |
92 | 92 | ||
93 | static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext; | 93 | static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext; |
94 | 94 | ||
@@ -602,26 +602,41 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
602 | int | 602 | int |
603 | main (int argc, char **argv) | 603 | main (int argc, char **argv) |
604 | { | 604 | { |
605 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 605 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
606 | { 'n', "num-peers", NULL, | 606 | |
607 | gettext_noop ("number of peers in consensus"), | 607 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
608 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, | 608 | "num-peers", |
609 | { 'D', "delay", NULL, | 609 | NULL, |
610 | gettext_noop ("dkg start delay"), | 610 | gettext_noop ("number of peers in consensus"), |
611 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &delay }, | 611 | &num_peers), |
612 | { 't', "timeout", NULL, | 612 | |
613 | gettext_noop ("dkg timeout"), | 613 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('D', |
614 | GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout }, | 614 | "delay", |
615 | { 'k', "threshold", NULL, | 615 | NULL, |
616 | gettext_noop ("threshold"), | 616 | gettext_noop ("dkg start delay"), |
617 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &threshold }, | 617 | &delay), |
618 | { 'd', "decrypt", NULL, | 618 | |
619 | gettext_noop ("also profile decryption"), | 619 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', |
620 | GNUNET_NO, &GNUNET_GETOPT_set_one, &decrypt }, | 620 | "timeout", |
621 | { 'V', "verbose", NULL, | 621 | NULL, |
622 | gettext_noop ("be more verbose (print received values)"), | 622 | gettext_noop ("dkg timeout"), |
623 | GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, | 623 | &timeout), |
624 | GNUNET_GETOPT_OPTION_END | 624 | |
625 | GNUNET_GETOPT_OPTION_SET_UINT ('k', | ||
626 | "threshold", | ||
627 | NULL, | ||
628 | gettext_noop ("threshold"), | ||
629 | &threshold), | ||
630 | |||
631 | GNUNET_GETOPT_OPTION_SET_ONE ('d', | ||
632 | "descrypt", | ||
633 | gettext_noop ("also profile decryption"), | ||
634 | &decrypt), | ||
635 | |||
636 | |||
637 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
638 | |||
639 | GNUNET_GETOPT_OPTION_END | ||
625 | }; | 640 | }; |
626 | delay = GNUNET_TIME_UNIT_ZERO; | 641 | delay = GNUNET_TIME_UNIT_ZERO; |
627 | timeout = GNUNET_TIME_UNIT_MINUTES; | 642 | timeout = GNUNET_TIME_UNIT_MINUTES; |
diff --git a/src/secretsharing/gnunet-service-secretsharing.c b/src/secretsharing/gnunet-service-secretsharing.c index fa35dc21b..6c281df86 100644 --- a/src/secretsharing/gnunet-service-secretsharing.c +++ b/src/secretsharing/gnunet-service-secretsharing.c | |||
@@ -720,7 +720,7 @@ keygen_round1_new_element (void *cls, | |||
720 | { | 720 | { |
721 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 721 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
722 | "keygen commit data with wrong size (%u) in consensus, " | 722 | "keygen commit data with wrong size (%u) in consensus, " |
723 | " %lu expected\n", | 723 | " %u expected\n", |
724 | element->size, sizeof (struct GNUNET_SECRETSHARING_KeygenCommitData)); | 724 | element->size, sizeof (struct GNUNET_SECRETSHARING_KeygenCommitData)); |
725 | return; | 725 | return; |
726 | } | 726 | } |
diff --git a/src/set/gnunet-set-ibf-profiler.c b/src/set/gnunet-set-ibf-profiler.c index 8d832e358..ac86a900d 100644 --- a/src/set/gnunet-set-ibf-profiler.c +++ b/src/set/gnunet-set-ibf-profiler.c | |||
@@ -244,24 +244,41 @@ run (void *cls, | |||
244 | int | 244 | int |
245 | main (int argc, char **argv) | 245 | main (int argc, char **argv) |
246 | { | 246 | { |
247 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 247 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
248 | {'A', "asize", NULL, | 248 | |
249 | gettext_noop ("number of element in set A-B"), 1, | 249 | GNUNET_GETOPT_OPTION_SET_UINT ('A', |
250 | &GNUNET_GETOPT_set_uint, &asize}, | 250 | "asize", |
251 | {'B', "bsize", NULL, | 251 | NULL, |
252 | gettext_noop ("number of element in set B-A"), 1, | 252 | gettext_noop ("number of element in set A-B"), |
253 | &GNUNET_GETOPT_set_uint, &bsize}, | 253 | &asize), |
254 | {'C', "csize", NULL, | 254 | |
255 | gettext_noop ("number of common elements in A and B"), 1, | 255 | GNUNET_GETOPT_OPTION_SET_UINT ('B', |
256 | &GNUNET_GETOPT_set_uint, &csize}, | 256 | "bsize", |
257 | {'k', "hash-num", NULL, | 257 | NULL, |
258 | gettext_noop ("hash num"), 1, | 258 | gettext_noop ("number of element in set B-A"), |
259 | &GNUNET_GETOPT_set_uint, &hash_num}, | 259 | &bsize), |
260 | {'s', "ibf-size", NULL, | 260 | |
261 | gettext_noop ("ibf size"), 1, | 261 | GNUNET_GETOPT_OPTION_SET_UINT ('C', |
262 | &GNUNET_GETOPT_set_uint, &ibf_size}, | 262 | "csize", |
263 | NULL, | ||
264 | gettext_noop ("number of common elements in A and B"), | ||
265 | &csize), | ||
266 | |||
267 | GNUNET_GETOPT_OPTION_SET_UINT ('k', | ||
268 | "hash-num", | ||
269 | NULL, | ||
270 | gettext_noop ("hash num"), | ||
271 | &hash_num), | ||
272 | |||
273 | GNUNET_GETOPT_OPTION_SET_UINT ('s', | ||
274 | "ibf-size", | ||
275 | NULL, | ||
276 | gettext_noop ("ibf size"), | ||
277 | &ibf_size), | ||
278 | |||
263 | GNUNET_GETOPT_OPTION_END | 279 | GNUNET_GETOPT_OPTION_END |
264 | }; | 280 | }; |
281 | |||
265 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-consensus-ibf", | 282 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-consensus-ibf", |
266 | "help", | 283 | "help", |
267 | options, &run, NULL, GNUNET_YES); | 284 | options, &run, NULL, GNUNET_YES); |
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c index 8404b191c..349bce6ea 100644 --- a/src/set/gnunet-set-profiler.c +++ b/src/set/gnunet-set-profiler.c | |||
@@ -59,8 +59,8 @@ static struct GNUNET_PeerIdentity local_peer; | |||
59 | static struct GNUNET_SET_ListenHandle *set_listener; | 59 | static struct GNUNET_SET_ListenHandle *set_listener; |
60 | 60 | ||
61 | static int byzantine; | 61 | static int byzantine; |
62 | static int force_delta; | 62 | static unsigned int force_delta; |
63 | static int force_full; | 63 | static unsigned int force_full; |
64 | static unsigned int element_size = 32; | 64 | static unsigned int element_size = 32; |
65 | 65 | ||
66 | /** | 66 | /** |
@@ -426,34 +426,60 @@ pre_run (void *cls, char *const *args, const char *cfgfile, | |||
426 | int | 426 | int |
427 | main (int argc, char **argv) | 427 | main (int argc, char **argv) |
428 | { | 428 | { |
429 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 429 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
430 | { 'A', "num-first", NULL, | 430 | GNUNET_GETOPT_OPTION_SET_UINT ('A', |
431 | gettext_noop ("number of values"), | 431 | "num-first", |
432 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_a }, | 432 | NULL, |
433 | { 'B', "num-second", NULL, | 433 | gettext_noop ("number of values"), |
434 | gettext_noop ("number of values"), | 434 | &num_a), |
435 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_b }, | 435 | |
436 | { 'b', "byzantine", NULL, | 436 | GNUNET_GETOPT_OPTION_SET_UINT ('B', |
437 | gettext_noop ("use byzantine mode"), | 437 | "num-second", |
438 | GNUNET_NO, &GNUNET_GETOPT_set_one, &byzantine }, | 438 | NULL, |
439 | { 'f', "force-full", NULL, | 439 | gettext_noop ("number of values"), |
440 | gettext_noop ("force sending full set"), | 440 | &num_b), |
441 | GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full }, | 441 | |
442 | { 'd', "force-delta", NULL, | 442 | GNUNET_GETOPT_OPTION_SET_ONE ('b', |
443 | gettext_noop ("number delta operation"), | 443 | "byzantine", |
444 | GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta }, | 444 | gettext_noop ("use byzantine mode"), |
445 | { 'C', "num-common", NULL, | 445 | &byzantine), |
446 | gettext_noop ("number of values"), | 446 | |
447 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c }, | 447 | GNUNET_GETOPT_OPTION_SET_UINT ('f', |
448 | { 'x', "operation", NULL, | 448 | "force-full", |
449 | gettext_noop ("operation to execute"), | 449 | NULL, |
450 | GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, | 450 | gettext_noop ("force sending full set"), |
451 | { 'w', "element-size", NULL, | 451 | &force_full), |
452 | gettext_noop ("element size"), | 452 | |
453 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &element_size }, | 453 | GNUNET_GETOPT_OPTION_SET_UINT ('d', |
454 | { 's', "statistics", NULL, | 454 | "force-delta", |
455 | gettext_noop ("write statistics to file"), | 455 | NULL, |
456 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, | 456 | gettext_noop ("number delta operation"), |
457 | &force_delta), | ||
458 | |||
459 | GNUNET_GETOPT_OPTION_SET_UINT ('C', | ||
460 | "num-common", | ||
461 | NULL, | ||
462 | gettext_noop ("number of values"), | ||
463 | &num_c), | ||
464 | |||
465 | GNUNET_GETOPT_OPTION_STRING ('x', | ||
466 | "operation", | ||
467 | NULL, | ||
468 | gettext_noop ("operation to execute"), | ||
469 | &op_str), | ||
470 | |||
471 | GNUNET_GETOPT_OPTION_SET_UINT ('w', | ||
472 | "element-size", | ||
473 | NULL, | ||
474 | gettext_noop ("element size"), | ||
475 | &element_size), | ||
476 | |||
477 | GNUNET_GETOPT_OPTION_FILENAME ('s', | ||
478 | "statistics", | ||
479 | "FILENAME", | ||
480 | gettext_noop ("write statistics to file"), | ||
481 | &statistics_filename), | ||
482 | |||
457 | GNUNET_GETOPT_OPTION_END | 483 | GNUNET_GETOPT_OPTION_END |
458 | }; | 484 | }; |
459 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler", | 485 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler", |
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index b864b828e..baeca3082 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c | |||
@@ -67,10 +67,10 @@ static int op_guest_leave; | |||
67 | static int op_guest_talk; | 67 | static int op_guest_talk; |
68 | 68 | ||
69 | /** --replay */ | 69 | /** --replay */ |
70 | static char *op_replay; | 70 | static int op_replay; |
71 | 71 | ||
72 | /** --replay-latest */ | 72 | /** --replay-latest */ |
73 | static char *op_replay_latest; | 73 | static int op_replay_latest; |
74 | 74 | ||
75 | /** --look-at */ | 75 | /** --look-at */ |
76 | static int op_look_at; | 76 | static int op_look_at; |
@@ -122,7 +122,7 @@ static uint64_t opt_start; | |||
122 | static uint64_t opt_until; | 122 | static uint64_t opt_until; |
123 | 123 | ||
124 | /** --limit */ | 124 | /** --limit */ |
125 | static int opt_limit; | 125 | static long long unsigned int opt_limit; |
126 | 126 | ||
127 | 127 | ||
128 | /* global vars */ | 128 | /* global vars */ |
@@ -1199,7 +1199,7 @@ int | |||
1199 | main (int argc, char *const *argv) | 1199 | main (int argc, char *const *argv) |
1200 | { | 1200 | { |
1201 | int res; | 1201 | int res; |
1202 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1202 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1203 | /* | 1203 | /* |
1204 | * gnunet program options in addition to the ones below: | 1204 | * gnunet program options in addition to the ones below: |
1205 | * | 1205 | * |
@@ -1212,120 +1212,165 @@ main (int argc, char *const *argv) | |||
1212 | 1212 | ||
1213 | /* operations */ | 1213 | /* operations */ |
1214 | 1214 | ||
1215 | { 'A', "host-assign", NULL, | 1215 | GNUNET_GETOPT_OPTION_SET_ONE ('A', |
1216 | gettext_noop ("assign --name in state to --data"), | 1216 | "host-assign", |
1217 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_assign }, | 1217 | gettext_noop ("assign --name in state to --data"), |
1218 | 1218 | &op_host_assign), | |
1219 | { 'B', "guest-leave", NULL, | 1219 | |
1220 | gettext_noop ("say good-bye and leave somebody else's place"), | 1220 | GNUNET_GETOPT_OPTION_SET_ONE ('B', |
1221 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, | 1221 | "guest-leave", |
1222 | 1222 | gettext_noop ("say good-bye and leave somebody else's place"), | |
1223 | { 'C', "host-enter", NULL, | 1223 | &op_guest_leave), |
1224 | gettext_noop ("create a place"), | 1224 | |
1225 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, | 1225 | GNUNET_GETOPT_OPTION_SET_ONE ('C', |
1226 | 1226 | "host-enter", | |
1227 | { 'D', "host-leave", NULL, | 1227 | gettext_noop ("create a place"), |
1228 | gettext_noop ("destroy a place we were hosting"), | 1228 | &op_host_enter), |
1229 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, | 1229 | |
1230 | 1230 | GNUNET_GETOPT_OPTION_SET_ONE ('C', | |
1231 | { 'E', "guest-enter", NULL, | 1231 | "host-enter", |
1232 | gettext_noop ("enter somebody else's place"), | 1232 | gettext_noop ("create a place"), |
1233 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, | 1233 | &op_host_enter), |
1234 | 1234 | ||
1235 | { 'F', "look-for", NULL, | 1235 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
1236 | gettext_noop ("find state matching name prefix"), | 1236 | "host-leave", |
1237 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, | 1237 | gettext_noop ("destroy a place we were hosting"), |
1238 | 1238 | &op_host_leave), | |
1239 | { 'H', "replay-latest", NULL, | 1239 | |
1240 | gettext_noop ("replay history of messages up to the given --limit"), | 1240 | GNUNET_GETOPT_OPTION_SET_ONE ('E', |
1241 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay_latest }, | 1241 | "guest-enter", |
1242 | 1242 | gettext_noop ("enter somebody else's place"), | |
1243 | { 'N', "host-reconnect", NULL, | 1243 | &op_guest_enter), |
1244 | gettext_noop ("reconnect to a previously created place"), | 1244 | |
1245 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, | 1245 | |
1246 | 1246 | GNUNET_GETOPT_OPTION_SET_ONE ('F', | |
1247 | { 'P', "host-announce", NULL, | 1247 | "look-for", |
1248 | gettext_noop ("publish something to a place we are hosting"), | 1248 | gettext_noop ("find state matching name prefix"), |
1249 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, | 1249 | &op_look_for), |
1250 | 1250 | ||
1251 | { 'R', "guest-reconnect", NULL, | 1251 | GNUNET_GETOPT_OPTION_SET_ONE ('H', |
1252 | gettext_noop ("reconnect to a previously entered place"), | 1252 | "replay-latest", |
1253 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, | 1253 | gettext_noop ("replay history of messages up to the given --limit"), |
1254 | 1254 | &op_replay_latest), | |
1255 | { 'S', "look-at", NULL, | 1255 | |
1256 | gettext_noop ("search for state matching exact name"), | 1256 | GNUNET_GETOPT_OPTION_SET_ONE ('N', |
1257 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at }, | 1257 | "host-reconnect", |
1258 | 1258 | gettext_noop ("reconnect to a previously created place"), | |
1259 | { 'T', "guest-talk", NULL, | 1259 | &op_host_reconnect), |
1260 | gettext_noop ("submit something to somebody's place"), | 1260 | |
1261 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, | 1261 | GNUNET_GETOPT_OPTION_SET_ONE ('P', |
1262 | 1262 | "host-announce", | |
1263 | { 'U', "status", NULL, | 1263 | gettext_noop ("publish something to a place we are hosting"), |
1264 | gettext_noop ("list of egos and subscribed places"), | 1264 | &op_host_announce), |
1265 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, | 1265 | |
1266 | 1266 | GNUNET_GETOPT_OPTION_SET_ONE ('R', | |
1267 | { 'X', "replay", NULL, | 1267 | "guest-reconnect", |
1268 | gettext_noop ("extract and replay history between message IDs --start and --until"), | 1268 | gettext_noop ("reconnect to a previously entered place"), |
1269 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_replay }, | 1269 | &op_guest_reconnect), |
1270 | |||
1271 | GNUNET_GETOPT_OPTION_SET_ONE ('S', | ||
1272 | "look-at", | ||
1273 | gettext_noop ("search for state matching exact name"), | ||
1274 | &op_look_at), | ||
1275 | |||
1276 | GNUNET_GETOPT_OPTION_SET_ONE ('T', | ||
1277 | "guest-talk", | ||
1278 | gettext_noop ("submit something to somebody's place"), | ||
1279 | &op_guest_talk), | ||
1280 | |||
1281 | GNUNET_GETOPT_OPTION_SET_ONE ('U', | ||
1282 | "status", | ||
1283 | gettext_noop ("list of egos and subscribed places"), | ||
1284 | &op_status), | ||
1285 | |||
1286 | GNUNET_GETOPT_OPTION_SET_ONE ('X', | ||
1287 | "replay", | ||
1288 | gettext_noop ("extract and replay history between message IDs --start and --until"), | ||
1289 | &op_replay), | ||
1270 | 1290 | ||
1271 | 1291 | ||
1272 | /* options */ | 1292 | /* options */ |
1273 | 1293 | ||
1274 | { 'a', "app", "APPLICATION_ID", | 1294 | GNUNET_GETOPT_OPTION_STRING ('a', |
1275 | gettext_noop ("application ID to use when connecting"), | 1295 | "app", |
1276 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app }, | 1296 | "APPLICATION_ID", |
1277 | 1297 | gettext_noop ("application ID to use when connecting"), | |
1278 | { 'd', "data", "DATA", | 1298 | &opt_app), |
1279 | gettext_noop ("message body or state value"), | 1299 | |
1280 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_data }, | 1300 | GNUNET_GETOPT_OPTION_STRING ('d', |
1281 | 1301 | "data", | |
1282 | { 'e', "ego", "NAME|PUBKEY", | 1302 | "DATA", |
1283 | gettext_noop ("name or public key of ego"), | 1303 | gettext_noop ("message body or state value"), |
1284 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego }, | 1304 | &opt_data), |
1285 | 1305 | ||
1286 | { 'f', "follow", NULL, | 1306 | GNUNET_GETOPT_OPTION_STRING ('e', |
1287 | gettext_noop ("wait for incoming messages"), | 1307 | "ego", |
1288 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow }, | 1308 | "NAME|PUBKEY", |
1289 | 1309 | gettext_noop ("name or public key of ego"), | |
1290 | { 'g', "gns", "GNS_NAME", | 1310 | &opt_ego), |
1291 | gettext_noop ("GNS name"), | 1311 | |
1292 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, | 1312 | GNUNET_GETOPT_OPTION_SET_ONE ('f', |
1293 | 1313 | "follow", | |
1294 | { 'i', "peer", "PEER_ID", | 1314 | gettext_noop ("wait for incoming messages"), |
1295 | gettext_noop ("peer ID for --guest-enter"), | 1315 | &opt_follow), |
1296 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, | 1316 | |
1297 | 1317 | GNUNET_GETOPT_OPTION_STRING ('g', | |
1298 | { 'k', "name", "VAR_NAME", | 1318 | "gns", |
1299 | gettext_noop ("name (key) to query from state"), | 1319 | "GNS_NAME", |
1300 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, | 1320 | gettext_noop ("GNS name"), |
1301 | 1321 | &opt_gns), | |
1302 | { 'm', "method", "METHOD_NAME", | 1322 | |
1303 | gettext_noop ("method name"), | 1323 | GNUNET_GETOPT_OPTION_STRING ('i', |
1304 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method }, | 1324 | "peer", |
1305 | 1325 | "PEER_ID", | |
1306 | { 'n', "limit", NULL, | 1326 | gettext_noop ("peer ID for --guest-enter"), |
1307 | gettext_noop ("number of messages to replay from history"), | 1327 | &opt_peer), |
1308 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, | 1328 | |
1309 | 1329 | GNUNET_GETOPT_OPTION_STRING ('k', | |
1310 | { 'p', "place", "PUBKEY", | 1330 | "name", |
1311 | gettext_noop ("key address of place"), | 1331 | "VAR_NAME", |
1312 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, | 1332 | gettext_noop ("name (key) to query from state"), |
1313 | 1333 | &opt_name), | |
1314 | { 's', "start", NULL, | 1334 | |
1315 | gettext_noop ("start message ID for history replay"), | 1335 | GNUNET_GETOPT_OPTION_STRING ('m', |
1316 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start }, | 1336 | "method", |
1317 | 1337 | "METHOD_NAME", | |
1318 | { 'w', "welcome", NULL, | 1338 | gettext_noop ("method name"), |
1319 | gettext_noop ("respond to entry requests by admitting all guests"), | 1339 | &opt_method), |
1320 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_welcome }, | 1340 | |
1321 | 1341 | GNUNET_GETOPT_OPTION_SET_ULONG ('n', | |
1322 | { 'u', "until", NULL, | 1342 | "limit", |
1323 | gettext_noop ("end message ID for history replay"), | 1343 | NULL, |
1324 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_until }, | 1344 | gettext_noop ("number of messages to replay from history"), |
1325 | 1345 | &opt_limit), | |
1326 | { 'y', "deny", NULL, | 1346 | |
1327 | gettext_noop ("respond to entry requests by refusing all guests"), | 1347 | GNUNET_GETOPT_OPTION_STRING ('p', |
1328 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_deny }, | 1348 | "place", |
1349 | "PUBKEY", | ||
1350 | gettext_noop ("key address of place"), | ||
1351 | &opt_place), | ||
1352 | |||
1353 | GNUNET_GETOPT_OPTION_SET_ULONG ('s', | ||
1354 | "start", | ||
1355 | NULL, | ||
1356 | gettext_noop ("start message ID for history replay"), | ||
1357 | &opt_start), | ||
1358 | |||
1359 | GNUNET_GETOPT_OPTION_SET_ONE ('w', | ||
1360 | "welcome", | ||
1361 | gettext_noop ("respond to entry requests by admitting all guests"), | ||
1362 | &opt_welcome), | ||
1363 | |||
1364 | GNUNET_GETOPT_OPTION_SET_ULONG ('u', | ||
1365 | "until", | ||
1366 | NULL, | ||
1367 | gettext_noop ("end message ID for history replay"), | ||
1368 | &opt_until), | ||
1369 | |||
1370 | GNUNET_GETOPT_OPTION_SET_ONE ('y', | ||
1371 | "deny", | ||
1372 | gettext_noop ("respond to entry requests by refusing all guests"), | ||
1373 | &opt_deny), | ||
1329 | 1374 | ||
1330 | GNUNET_GETOPT_OPTION_END | 1375 | GNUNET_GETOPT_OPTION_END |
1331 | }; | 1376 | }; |
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index ed0c3f27d..6cfc56171 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -378,28 +378,44 @@ run (void *cls, | |||
378 | int | 378 | int |
379 | main (int argc, char *const *argv) | 379 | main (int argc, char *const *argv) |
380 | { | 380 | { |
381 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 381 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
382 | {'n', "name", "NAME", | 382 | GNUNET_GETOPT_OPTION_STRING ('n', |
383 | gettext_noop ("limit output to statistics for the given NAME"), 1, | 383 | "name", |
384 | &GNUNET_GETOPT_set_string, &name}, | 384 | "NAME", |
385 | {'p', "persistent", NULL, | 385 | gettext_noop ("limit output to statistics for the given NAME"), |
386 | gettext_noop ("make the value being set persistent"), 0, | 386 | &name), |
387 | &GNUNET_GETOPT_set_one, &persistent}, | 387 | |
388 | {'s', "subsystem", "SUBSYSTEM", | 388 | GNUNET_GETOPT_OPTION_SET_ONE ('p', |
389 | gettext_noop ("limit output to the given SUBSYSTEM"), 1, | 389 | "persistent", |
390 | &GNUNET_GETOPT_set_string, &subsystem}, | 390 | gettext_noop ("make the value being set persistent"), |
391 | {'q', "quiet", NULL, | 391 | &persistent), |
392 | gettext_noop ("just print the statistics value"), 0, | 392 | |
393 | &GNUNET_GETOPT_set_one, &quiet}, | 393 | GNUNET_GETOPT_OPTION_STRING ('s', |
394 | {'w', "watch", NULL, | 394 | "subsystem", |
395 | gettext_noop ("watch value continuously"), 0, | 395 | "SUBSYSTEM", |
396 | &GNUNET_GETOPT_set_one, &watch}, | 396 | gettext_noop ("limit output to the given SUBSYSTEM"), |
397 | {'r', "remote", NULL, | 397 | &subsystem), |
398 | gettext_noop ("connect to remote host"), 1, | 398 | |
399 | &GNUNET_GETOPT_set_string, &remote_host}, | 399 | GNUNET_GETOPT_OPTION_SET_ONE ('q', |
400 | {'o', "port", NULL, | 400 | "quiet", |
401 | gettext_noop ("port for remote host"), 1, | 401 | gettext_noop ("just print the statistics value"), |
402 | &GNUNET_GETOPT_set_uint, &remote_port}, | 402 | &quiet), |
403 | |||
404 | GNUNET_GETOPT_OPTION_SET_ONE ('w', | ||
405 | "watch", | ||
406 | gettext_noop ("watch value continuously"), | ||
407 | &watch), | ||
408 | |||
409 | GNUNET_GETOPT_OPTION_STRING ('r', | ||
410 | "remote", | ||
411 | "REMOTE", | ||
412 | gettext_noop ("connect to remote host"), | ||
413 | &remote_host), | ||
414 | GNUNET_GETOPT_OPTION_SET_ULONG ('o', | ||
415 | "port", | ||
416 | "PORT", | ||
417 | gettext_noop ("port for remote host"), | ||
418 | &remote_port), | ||
403 | GNUNET_GETOPT_OPTION_END | 419 | GNUNET_GETOPT_OPTION_END |
404 | }; | 420 | }; |
405 | remote_port = 0; | 421 | remote_port = 0; |
diff --git a/src/testbed/generate-underlay-topology.c b/src/testbed/generate-underlay-topology.c index 36580a2a3..ab7d81c8b 100644 --- a/src/testbed/generate-underlay-topology.c +++ b/src/testbed/generate-underlay-topology.c | |||
@@ -70,7 +70,7 @@ enum GNUNET_TESTBED_TopologyOption topology; | |||
70 | /** | 70 | /** |
71 | * The number of peers to include in the topology | 71 | * The number of peers to include in the topology |
72 | */ | 72 | */ |
73 | static int num_peers; | 73 | static unsigned int num_peers; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * program result | 76 | * program result |
@@ -335,11 +335,15 @@ int | |||
335 | main (int argc, char *const argv[]) | 335 | main (int argc, char *const argv[]) |
336 | { | 336 | { |
337 | struct GNUNET_GETOPT_CommandLineOption option[] = { | 337 | struct GNUNET_GETOPT_CommandLineOption option[] = { |
338 | {'p', "num-peers", "COUNT", | 338 | |
339 | gettext_noop ("create COUNT number of peers"), | 339 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
340 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers}, | 340 | "num-peers", |
341 | "COUNT", | ||
342 | gettext_noop ("create COUNT number of peers"), | ||
343 | &num_peers), | ||
341 | GNUNET_GETOPT_OPTION_END | 344 | GNUNET_GETOPT_OPTION_END |
342 | }; | 345 | }; |
346 | |||
343 | int ret; | 347 | int ret; |
344 | 348 | ||
345 | exit_result = GNUNET_SYSERR; | 349 | exit_result = GNUNET_SYSERR; |
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index 9468b3c91..29f77193d 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -276,23 +276,34 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
276 | int | 276 | int |
277 | main (int argc, char *const *argv) | 277 | main (int argc, char *const *argv) |
278 | { | 278 | { |
279 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 279 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
280 | {'p', "num-peers", "COUNT", | 280 | |
281 | gettext_noop ("create COUNT number of peers"), | 281 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
282 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers}, | 282 | "num-peers", |
283 | {'e', "num-errors", "COUNT", | 283 | "COUNT", |
284 | gettext_noop ("tolerate COUNT number of continious timeout failures"), | 284 | gettext_noop ("create COUNT number of peers"), |
285 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails}, | 285 | &num_peers), |
286 | {'n', "non-interactive", NULL, | 286 | |
287 | gettext_noop ("run profiler in non-interactive mode where upon " | 287 | GNUNET_GETOPT_OPTION_SET_UINT ('e', |
288 | "testbed setup the profiler does not wait for a " | 288 | "num-errors", |
289 | "keystroke but continues to run until a termination " | 289 | "COUNT", |
290 | "signal is received"), | 290 | gettext_noop ("tolerate COUNT number of continious timeout failures"), |
291 | GNUNET_NO, &GNUNET_GETOPT_set_one, &noninteractive}, | 291 | &num_cont_fails), |
292 | |||
293 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
294 | "non-interactive", | ||
295 | gettext_noop ("run profiler in non-interactive mode where upon " | ||
296 | "testbed setup the profiler does not wait for a " | ||
297 | "keystroke but continues to run until a termination " | ||
298 | "signal is received"), | ||
299 | &noninteractive), | ||
300 | |||
292 | #if !ENABLE_SUPERMUC | 301 | #if !ENABLE_SUPERMUC |
293 | {'H', "hosts", "FILENAME", | 302 | GNUNET_GETOPT_OPTION_STRING ('H', |
294 | gettext_noop ("name of the file with the login information for the testbed"), | 303 | "hosts", |
295 | GNUNET_YES, &GNUNET_GETOPT_set_string, &hosts_file}, | 304 | "FILENAME", |
305 | gettext_noop ("name of the file with the login information for the testbed"), | ||
306 | &hosts_file), | ||
296 | #endif | 307 | #endif |
297 | GNUNET_GETOPT_OPTION_END | 308 | GNUNET_GETOPT_OPTION_END |
298 | }; | 309 | }; |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index 07f1560cb..686b38192 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -348,17 +348,35 @@ run_no_scheduler (void *cls, char *const *args, const char *cfgfile, | |||
348 | int | 348 | int |
349 | main (int argc, char *const *argv) | 349 | main (int argc, char *const *argv) |
350 | { | 350 | { |
351 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 351 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
352 | {'C', "cfg", NULL, gettext_noop ("create unique configuration files"), | 352 | GNUNET_GETOPT_OPTION_SET_ONE ('C', |
353 | GNUNET_NO, &GNUNET_GETOPT_set_one, &create_cfg}, | 353 | "cfg", |
354 | {'k', "key", "FILENAME", gettext_noop ("extract hostkey file from pre-computed hostkey list"), | 354 | gettext_noop ("create unique configuration files"), |
355 | GNUNET_YES, &GNUNET_GETOPT_set_string, &create_hostkey}, | 355 | &create_cfg), |
356 | {'n', "number", "NUMBER", gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"), | 356 | GNUNET_GETOPT_OPTION_STRING ('k', |
357 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &create_no}, | 357 | "key", |
358 | {'t', "template", "FILENAME", gettext_noop ("configuration template"), | 358 | "FILENAME", |
359 | GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template}, | 359 | gettext_noop ("extract hostkey file from pre-computed hostkey list"), |
360 | {'r', "run", "SERVICE", gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"), | 360 | &create_hostkey), |
361 | GNUNET_YES, &GNUNET_GETOPT_set_string, &run_service_name}, | 361 | |
362 | GNUNET_GETOPT_OPTION_SET_UINT ('n', | ||
363 | "number", | ||
364 | "NUMBER", | ||
365 | gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"), | ||
366 | &create_no), | ||
367 | |||
368 | |||
369 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
370 | "template", | ||
371 | "FILENAME", | ||
372 | gettext_noop ("configuration template"), | ||
373 | &create_cfg_template), | ||
374 | |||
375 | GNUNET_GETOPT_OPTION_STRING ('r', | ||
376 | "run", | ||
377 | "SERVICE", | ||
378 | gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"), | ||
379 | &run_service_name), | ||
362 | GNUNET_GETOPT_OPTION_END | 380 | GNUNET_GETOPT_OPTION_END |
363 | }; | 381 | }; |
364 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 382 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/testing/list-keys.c b/src/testing/list-keys.c index 1fd46ebf2..cfb49460a 100644 --- a/src/testing/list-keys.c +++ b/src/testing/list-keys.c | |||
@@ -6,10 +6,6 @@ static unsigned int nkeys; | |||
6 | static unsigned int nskip; | 6 | static unsigned int nskip; |
7 | static int result; | 7 | static int result; |
8 | 8 | ||
9 | |||
10 | |||
11 | |||
12 | |||
13 | /** | 9 | /** |
14 | * Main run function. | 10 | * Main run function. |
15 | * | 11 | * |
@@ -87,12 +83,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
87 | int main (int argc, char *argv[]) | 83 | int main (int argc, char *argv[]) |
88 | { | 84 | { |
89 | struct GNUNET_GETOPT_CommandLineOption option[] = { | 85 | struct GNUNET_GETOPT_CommandLineOption option[] = { |
90 | {'n', "num-keys", "COUNT", | 86 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
91 | gettext_noop ("list COUNT number of keys"), | 87 | "num-keys", |
92 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &nkeys}, | 88 | "COUNT", |
93 | {'s', "skip", "COUNT", | 89 | gettext_noop ("list COUNT number of keys"), |
94 | gettext_noop ("skip COUNT number of keys in the beginning"), | 90 | &nkeys), |
95 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &nskip}, | ||
96 | GNUNET_GETOPT_OPTION_END | 91 | GNUNET_GETOPT_OPTION_END |
97 | }; | 92 | }; |
98 | int ret; | 93 | int ret; |
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index dceff7e3b..bd4d3072b 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -151,7 +151,7 @@ static struct GNUNET_PeerIdentity pid; | |||
151 | /** | 151 | /** |
152 | * Selected level of verbosity. | 152 | * Selected level of verbosity. |
153 | */ | 153 | */ |
154 | static int verbosity; | 154 | static unsigned int verbosity; |
155 | 155 | ||
156 | 156 | ||
157 | /** | 157 | /** |
@@ -610,26 +610,36 @@ main (int argc, char * const *argv) | |||
610 | benchmark_iterations = DEFAULT_ITERATION_COUNT; | 610 | benchmark_iterations = DEFAULT_ITERATION_COUNT; |
611 | benchmark_running = GNUNET_NO; | 611 | benchmark_running = GNUNET_NO; |
612 | 612 | ||
613 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 613 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
614 | 614 | ||
615 | { 's', "send", NULL, | 615 | GNUNET_GETOPT_OPTION_SET_ONE ('s', |
616 | gettext_noop ("send data to peer"), | 616 | "send", |
617 | 0, &GNUNET_GETOPT_set_one, &benchmark_send}, | 617 | gettext_noop ("send data to peer"), |
618 | { 'r', "receive", NULL, gettext_noop | 618 | &benchmark_send), |
619 | ("receive data from peer"), 0, | 619 | GNUNET_GETOPT_OPTION_SET_ONE ('r', |
620 | &GNUNET_GETOPT_set_one, &benchmark_receive}, | 620 | "receive", |
621 | { 'i', "iterations", NULL, gettext_noop | 621 | gettext_noop ("receive data from peer"), |
622 | ("iterations"), 1, | 622 | &benchmark_receive), |
623 | &GNUNET_GETOPT_set_uint, &benchmark_iterations}, | 623 | GNUNET_GETOPT_OPTION_SET_UINT ('i', |
624 | { 'n', "number", NULL, gettext_noop | 624 | "iterations", |
625 | ("number of messages to send"), 1, | 625 | NULL, |
626 | &GNUNET_GETOPT_set_uint, &benchmark_count}, | 626 | gettext_noop ("iterations"), |
627 | { 'm', "messagesize", NULL, gettext_noop | 627 | &benchmark_iterations), |
628 | ("message size to use"), 1, | 628 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
629 | &GNUNET_GETOPT_set_uint, &benchmark_size}, | 629 | "number", |
630 | { 'p', "peer", "PEER", | 630 | NULL, |
631 | gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, | 631 | gettext_noop ("number of messages to send"), |
632 | &cpid }, | 632 | &benchmark_count), |
633 | GNUNET_GETOPT_OPTION_SET_UINT ('m', | ||
634 | "messagesize", | ||
635 | NULL, | ||
636 | gettext_noop ("message size to use"), | ||
637 | &benchmark_size), | ||
638 | GNUNET_GETOPT_OPTION_STRING ('p', | ||
639 | "peer", | ||
640 | "PEER", | ||
641 | gettext_noop ("peer identity"), | ||
642 | &cpid), | ||
633 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 643 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
634 | GNUNET_GETOPT_OPTION_END | 644 | GNUNET_GETOPT_OPTION_END |
635 | }; | 645 | }; |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index fcfc94ac8..c0442950d 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -295,7 +295,7 @@ static struct GNUNET_SCHEDULER_Task *op_timeout; | |||
295 | /** | 295 | /** |
296 | * Selected level of verbosity. | 296 | * Selected level of verbosity. |
297 | */ | 297 | */ |
298 | static int verbosity; | 298 | static unsigned int verbosity; |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * Resolver process handle. | 301 | * Resolver process handle. |
@@ -1439,37 +1439,49 @@ main (int argc, | |||
1439 | char * const *argv) | 1439 | char * const *argv) |
1440 | { | 1440 | { |
1441 | int res; | 1441 | int res; |
1442 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1442 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1443 | { 'a', "all", NULL, | 1443 | GNUNET_GETOPT_OPTION_SET_ONE ('a', |
1444 | gettext_noop ("print information for all peers (instead of only connected peers)"), | 1444 | "all", |
1445 | 0, &GNUNET_GETOPT_set_one, &iterate_all }, | 1445 | gettext_noop ("print information for all peers (instead of only connected peers)"), |
1446 | { 'b', "benchmark", NULL, | 1446 | &iterate_all), |
1447 | gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), | 1447 | GNUNET_GETOPT_OPTION_SET_ONE ('b', |
1448 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive }, | 1448 | "benchmark", |
1449 | { 'D', "disconnect", | 1449 | gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), |
1450 | NULL, gettext_noop ("disconnect from a peer"), 0, | 1450 | &benchmark_receive), |
1451 | &GNUNET_GETOPT_set_one, &do_disconnect }, | 1451 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
1452 | { 'i', "information", NULL, | 1452 | "disconnect", |
1453 | gettext_noop ("provide information about all current connections (once)"), | 1453 | gettext_noop ("disconnect from a peer"), |
1454 | 0, &GNUNET_GETOPT_set_one, &iterate_connections }, | 1454 | &do_disconnect), |
1455 | { 'm', "monitor", NULL, | 1455 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
1456 | gettext_noop ("provide information about all current connections (continuously)"), | 1456 | "information", |
1457 | 0, &GNUNET_GETOPT_set_one, &monitor_connections }, | 1457 | gettext_noop ("provide information about all current connections (once)"), |
1458 | { 'e', "events", NULL, | 1458 | &iterate_connections), |
1459 | gettext_noop ("provide information about all connects and disconnect events (continuously)"), | 1459 | GNUNET_GETOPT_OPTION_SET_ONE ('m', |
1460 | 0, &GNUNET_GETOPT_set_one, &monitor_connects }, | 1460 | "monitor", |
1461 | { 'n', "numeric", | 1461 | gettext_noop ("provide information about all current connections (continuously)"), |
1462 | NULL, gettext_noop ("do not resolve hostnames"), 0, | 1462 | &monitor_connections), |
1463 | &GNUNET_GETOPT_set_one, &numeric }, | 1463 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
1464 | { 'p', "peer", "PEER", | 1464 | "events", |
1465 | gettext_noop ("peer identity"), 1, &GNUNET_GETOPT_set_string, | 1465 | gettext_noop ("provide information about all connects and disconnect events (continuously)"), |
1466 | &cpid }, | 1466 | &monitor_connects), |
1467 | { 'P', "plugins", NULL, | 1467 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
1468 | gettext_noop ("monitor plugin sessions"), 0, &GNUNET_GETOPT_set_one, | 1468 | "numeric", |
1469 | &monitor_plugins }, | 1469 | gettext_noop ("do not resolve hostnames"), |
1470 | { 's', "send", NULL, gettext_noop | 1470 | &numeric), |
1471 | ("send data for benchmarking to the other peer (until CTRL-C)"), 0, | 1471 | GNUNET_GETOPT_OPTION_STRING ('p', |
1472 | &GNUNET_GETOPT_set_one, &benchmark_send }, | 1472 | "peer", |
1473 | "PEER", | ||
1474 | gettext_noop ("peer identity"), | ||
1475 | &cpid), | ||
1476 | GNUNET_GETOPT_OPTION_SET_ONE ('P', | ||
1477 | "plugins", | ||
1478 | gettext_noop ("monitor plugin sessions"), | ||
1479 | &monitor_plugins), | ||
1480 | GNUNET_GETOPT_OPTION_SET_ONE ('s', | ||
1481 | "send", | ||
1482 | gettext_noop | ||
1483 | ("send data for benchmarking to the other peer (until CTRL-C)"), | ||
1484 | &benchmark_send), | ||
1473 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 1485 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
1474 | GNUNET_GETOPT_OPTION_END | 1486 | GNUNET_GETOPT_OPTION_END |
1475 | }; | 1487 | }; |
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c index c55d586f3..050a38acc 100644 --- a/src/transport/tcp_service_legacy.c +++ b/src/transport/tcp_service_legacy.c | |||
@@ -1393,9 +1393,10 @@ GNUNET_SERVICE_run (int argc, char *const *argv, | |||
1393 | 1393 | ||
1394 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { | 1394 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { |
1395 | GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_fn), | 1395 | GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_fn), |
1396 | {'d', "daemonize", NULL, | 1396 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
1397 | gettext_noop ("do daemonize (detach from terminal)"), 0, | 1397 | "daemonize", |
1398 | GNUNET_GETOPT_set_one, &do_daemonize}, | 1398 | gettext_noop ("do daemonize (detach from terminal)"), |
1399 | &do_daemonize), | ||
1399 | GNUNET_GETOPT_OPTION_HELP (NULL), | 1400 | GNUNET_GETOPT_OPTION_HELP (NULL), |
1400 | GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), | 1401 | GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), |
1401 | GNUNET_GETOPT_OPTION_LOGFILE (&logfile), | 1402 | GNUNET_GETOPT_OPTION_LOGFILE (&logfile), |
diff --git a/src/util/getopt.c b/src/util/getopt.c index ff62dba9b..036e0f4be 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c | |||
@@ -26,7 +26,7 @@ USA. | |||
26 | 26 | ||
27 | 27 | ||
28 | This code was heavily modified for GNUnet. | 28 | This code was heavily modified for GNUnet. |
29 | Copyright Copyright (C) 2006 Christian Grothoff | 29 | Copyright Copyright (C) 2006, 2017 Christian Grothoff |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /** | 32 | /** |
@@ -845,9 +845,13 @@ GN_getopt_internal (int argc, char *const *argv, const char *optstring, | |||
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | |||
848 | static int | 849 | static int |
849 | GNgetopt_long (int argc, char *const *argv, const char *options, | 850 | GNgetopt_long (int argc, |
850 | const struct GNoption *long_options, int *opt_index) | 851 | char *const *argv, |
852 | const char *options, | ||
853 | const struct GNoption *long_options, | ||
854 | int *opt_index) | ||
851 | { | 855 | { |
852 | return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0); | 856 | return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0); |
853 | } | 857 | } |
@@ -867,16 +871,17 @@ GNgetopt_long (int argc, char *const *argv, const char *options, | |||
867 | int | 871 | int |
868 | GNUNET_GETOPT_run (const char *binaryOptions, | 872 | GNUNET_GETOPT_run (const char *binaryOptions, |
869 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, | 873 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, |
870 | unsigned int argc, char *const *argv) | 874 | unsigned int argc, |
875 | char *const *argv) | ||
871 | { | 876 | { |
872 | struct GNoption *long_options; | 877 | struct GNoption *long_options; |
873 | struct GNUNET_GETOPT_CommandLineProcessorContext clpc; | 878 | struct GNUNET_GETOPT_CommandLineProcessorContext clpc; |
874 | int count; | 879 | int count; |
875 | int i; | ||
876 | char *shorts; | 880 | char *shorts; |
877 | int spos; | 881 | int spos; |
878 | int cont; | 882 | int cont; |
879 | int c; | 883 | int c; |
884 | uint8_t *seen; | ||
880 | 885 | ||
881 | GNUNET_assert (argc > 0); | 886 | GNUNET_assert (argc > 0); |
882 | GNoptind = 0; | 887 | GNoptind = 0; |
@@ -885,13 +890,15 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
885 | clpc.allOptions = allOptions; | 890 | clpc.allOptions = allOptions; |
886 | clpc.argv = argv; | 891 | clpc.argv = argv; |
887 | clpc.argc = argc; | 892 | clpc.argc = argc; |
888 | count = 0; | 893 | for (count = 0; NULL != allOptions[count].name; count++) ; |
889 | while (allOptions[count].name != NULL) | 894 | |
890 | count++; | 895 | long_options = GNUNET_new_array (count + 1, |
891 | long_options = GNUNET_malloc (sizeof (struct GNoption) * (count + 1)); | 896 | struct GNoption); |
897 | seen = GNUNET_new_array (count, | ||
898 | uint8_t); | ||
892 | shorts = GNUNET_malloc (count * 2 + 1); | 899 | shorts = GNUNET_malloc (count * 2 + 1); |
893 | spos = 0; | 900 | spos = 0; |
894 | for (i = 0; i < count; i++) | 901 | for (unsigned i = 0; i < count; i++) |
895 | { | 902 | { |
896 | long_options[i].name = allOptions[i].name; | 903 | long_options[i].name = allOptions[i].name; |
897 | long_options[i].has_arg = allOptions[i].require_argument; | 904 | long_options[i].has_arg = allOptions[i].require_argument; |
@@ -907,13 +914,17 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
907 | long_options[count].val = '\0'; | 914 | long_options[count].val = '\0'; |
908 | shorts[spos] = '\0'; | 915 | shorts[spos] = '\0'; |
909 | cont = GNUNET_OK; | 916 | cont = GNUNET_OK; |
917 | |||
910 | /* main getopt loop */ | 918 | /* main getopt loop */ |
911 | while (cont == GNUNET_OK) | 919 | while (GNUNET_OK == cont) |
912 | { | 920 | { |
913 | int option_index = 0; | 921 | int option_index = 0; |
922 | unsigned int i; | ||
914 | 923 | ||
915 | c = GNgetopt_long (argc, argv, shorts, long_options, &option_index); | 924 | c = GNgetopt_long (argc, argv, |
916 | 925 | shorts, | |
926 | long_options, | ||
927 | &option_index); | ||
917 | if (c == GNUNET_SYSERR) | 928 | if (c == GNUNET_SYSERR) |
918 | break; /* No more flags to process */ | 929 | break; /* No more flags to process */ |
919 | 930 | ||
@@ -922,25 +933,46 @@ GNUNET_GETOPT_run (const char *binaryOptions, | |||
922 | clpc.currentArgument = GNoptind - 1; | 933 | clpc.currentArgument = GNoptind - 1; |
923 | if ((char) c == allOptions[i].shortName) | 934 | if ((char) c == allOptions[i].shortName) |
924 | { | 935 | { |
925 | cont = | 936 | cont = allOptions[i].processor (&clpc, |
926 | allOptions[i].processor (&clpc, allOptions[i].scls, | 937 | allOptions[i].scls, |
927 | allOptions[i].name, GNoptarg); | 938 | allOptions[i].name, |
939 | GNoptarg); | ||
940 | seen[i] = 1; | ||
928 | break; | 941 | break; |
929 | } | 942 | } |
930 | } | 943 | } |
931 | if (i == count) | 944 | if (i == count) |
932 | { | 945 | { |
933 | FPRINTF (stderr, _("Use %s to get a list of options.\n"), "--help"); | 946 | FPRINTF (stderr, |
947 | _("Use %s to get a list of options.\n"), | ||
948 | "--help"); | ||
934 | cont = GNUNET_SYSERR; | 949 | cont = GNUNET_SYSERR; |
935 | } | 950 | } |
936 | } | 951 | } |
937 | |||
938 | GNUNET_free (shorts); | 952 | GNUNET_free (shorts); |
939 | GNUNET_free (long_options); | 953 | GNUNET_free (long_options); |
940 | if (cont != GNUNET_OK) | 954 | |
955 | if (GNUNET_YES == cont) | ||
941 | { | 956 | { |
942 | return cont; | 957 | for (count = 0; NULL != allOptions[count].name; count++) |
958 | if ( (0 == seen[count]) && | ||
959 | (allOptions[count].option_mandatory) ) | ||
960 | { | ||
961 | FPRINTF (stderr, | ||
962 | _("Missing mandatory option `%s'.\n"), | ||
963 | allOptions[count].name); | ||
964 | cont = GNUNET_SYSERR; | ||
965 | } | ||
943 | } | 966 | } |
967 | GNUNET_free (seen); | ||
968 | |||
969 | /* call cleaners, if available */ | ||
970 | for (count = 0; NULL != allOptions[count].name; count++) | ||
971 | if (NULL != allOptions[count].cleaner) | ||
972 | allOptions[count].cleaner (allOptions[count].scls); | ||
973 | |||
974 | if (GNUNET_OK != cont) | ||
975 | return cont; | ||
944 | return GNoptind; | 976 | return GNoptind; |
945 | } | 977 | } |
946 | 978 | ||
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index 4d7104503..76342a6c9 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c | |||
@@ -38,11 +38,11 @@ | |||
38 | * @param value not used (NULL) | 38 | * @param value not used (NULL) |
39 | * @return #GNUNET_NO (do not continue, not an error) | 39 | * @return #GNUNET_NO (do not continue, not an error) |
40 | */ | 40 | */ |
41 | int | 41 | static int |
42 | GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 42 | print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
43 | void *scls, | 43 | void *scls, |
44 | const char *option, | 44 | const char *option, |
45 | const char *value) | 45 | const char *value) |
46 | { | 46 | { |
47 | const char *version = scls; | 47 | const char *version = scls; |
48 | 48 | ||
@@ -54,6 +54,26 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext * | |||
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Define the option to print the version of | ||
58 | * the application (-v option) | ||
59 | * | ||
60 | * @param version string with the version number | ||
61 | */ | ||
62 | struct GNUNET_GETOPT_CommandLineOption | ||
63 | GNUNET_GETOPT_OPTION_VERSION (const char *version) | ||
64 | { | ||
65 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
66 | .shortName = 'v', | ||
67 | .name = "version", | ||
68 | .description = gettext_noop("print the version number"), | ||
69 | .processor = &print_version, | ||
70 | .scls = (void *) version | ||
71 | }; | ||
72 | return clo; | ||
73 | } | ||
74 | |||
75 | |||
76 | /** | ||
57 | * At what offset does the help text start? | 77 | * At what offset does the help text start? |
58 | */ | 78 | */ |
59 | #define BORDER 29 | 79 | #define BORDER 29 |
@@ -67,11 +87,11 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext * | |||
67 | * @param value not used (NULL) | 87 | * @param value not used (NULL) |
68 | * @return #GNUNET_NO (do not continue, not an error) | 88 | * @return #GNUNET_NO (do not continue, not an error) |
69 | */ | 89 | */ |
70 | int | 90 | static int |
71 | GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 91 | format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
72 | void *scls, | 92 | void *scls, |
73 | const char *option, | 93 | const char *option, |
74 | const char *value) | 94 | const char *value) |
75 | { | 95 | { |
76 | const char *about = scls; | 96 | const char *about = scls; |
77 | size_t slen; | 97 | size_t slen; |
@@ -165,6 +185,27 @@ OUTER: | |||
165 | 185 | ||
166 | 186 | ||
167 | /** | 187 | /** |
188 | * Defining the option to print the command line | ||
189 | * help text (-h option). | ||
190 | * | ||
191 | * @param about string with brief description of the application | ||
192 | */ | ||
193 | struct GNUNET_GETOPT_CommandLineOption | ||
194 | GNUNET_GETOPT_OPTION_HELP (const char *about) | ||
195 | { | ||
196 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
197 | .shortName = 'h', | ||
198 | .name = "help", | ||
199 | .description = gettext_noop("print this help"), | ||
200 | .processor = format_help, | ||
201 | .scls = (void *) about | ||
202 | }; | ||
203 | |||
204 | return clo; | ||
205 | } | ||
206 | |||
207 | |||
208 | /** | ||
168 | * Set an option of type 'unsigned int' from the command line. Each | 209 | * Set an option of type 'unsigned int' from the command line. Each |
169 | * time the option flag is given, the value is incremented by one. | 210 | * time the option flag is given, the value is incremented by one. |
170 | * A pointer to this function should be passed as part of the | 211 | * A pointer to this function should be passed as part of the |
@@ -173,17 +214,18 @@ OUTER: | |||
173 | * type 'int'. | 214 | * type 'int'. |
174 | * | 215 | * |
175 | * @param ctx command line processing context | 216 | * @param ctx command line processing context |
176 | * @param scls additional closure (will point to the 'int') | 217 | * @param scls additional closure (will point to the 'unsigned int') |
177 | * @param option name of the option | 218 | * @param option name of the option |
178 | * @param value not used (NULL) | 219 | * @param value not used (NULL) |
179 | * @return #GNUNET_OK | 220 | * @return #GNUNET_OK |
180 | */ | 221 | */ |
181 | int | 222 | static int |
182 | GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext | 223 | increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
183 | *ctx, void *scls, const char *option, | 224 | void *scls, |
184 | const char *value) | 225 | const char *option, |
226 | const char *value) | ||
185 | { | 227 | { |
186 | int *val = scls; | 228 | unsigned int *val = scls; |
187 | 229 | ||
188 | (*val)++; | 230 | (*val)++; |
189 | return GNUNET_OK; | 231 | return GNUNET_OK; |
@@ -191,6 +233,54 @@ GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
191 | 233 | ||
192 | 234 | ||
193 | /** | 235 | /** |
236 | * Increment @a val each time the option flag is given by one. | ||
237 | * | ||
238 | * @param shortName short name of the option | ||
239 | * @param name long name of the option | ||
240 | * @param argumentHelp help text for the option argument | ||
241 | * @param description long help text for the option | ||
242 | * @param[out] val increment by 1 each time the option is present | ||
243 | */ | ||
244 | struct GNUNET_GETOPT_CommandLineOption | ||
245 | GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName, | ||
246 | const char *name, | ||
247 | const char *description, | ||
248 | unsigned int *val) | ||
249 | { | ||
250 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
251 | .shortName = shortName, | ||
252 | .name = name, | ||
253 | .description = description, | ||
254 | .processor = &increment_value, | ||
255 | .scls = (void *) val | ||
256 | }; | ||
257 | |||
258 | return clo; | ||
259 | } | ||
260 | |||
261 | |||
262 | /** | ||
263 | * Define the '-V' verbosity option. Using the option more | ||
264 | * than once increments @a level each time. | ||
265 | * | ||
266 | * @param[out] level set to the verbosity level | ||
267 | */ | ||
268 | struct GNUNET_GETOPT_CommandLineOption | ||
269 | GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level) | ||
270 | { | ||
271 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
272 | .shortName = 'V', | ||
273 | .name = "verbose", | ||
274 | .description = gettext_noop("be verbose"), | ||
275 | .processor = &increment_value, | ||
276 | .scls = (void *) level | ||
277 | }; | ||
278 | |||
279 | return clo; | ||
280 | } | ||
281 | |||
282 | |||
283 | /** | ||
194 | * Set an option of type 'int' from the command line to 1 if the | 284 | * Set an option of type 'int' from the command line to 1 if the |
195 | * given option is present. | 285 | * given option is present. |
196 | * A pointer to this function should be passed as part of the | 286 | * A pointer to this function should be passed as part of the |
@@ -204,9 +294,11 @@ GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
204 | * @param value not used (NULL) | 294 | * @param value not used (NULL) |
205 | * @return #GNUNET_OK | 295 | * @return #GNUNET_OK |
206 | */ | 296 | */ |
207 | int | 297 | static int |
208 | GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 298 | set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
209 | void *scls, const char *option, const char *value) | 299 | void *scls, |
300 | const char *option, | ||
301 | const char *value) | ||
210 | { | 302 | { |
211 | int *val = scls; | 303 | int *val = scls; |
212 | 304 | ||
@@ -216,6 +308,34 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
216 | 308 | ||
217 | 309 | ||
218 | /** | 310 | /** |
311 | * Allow user to specify a flag (which internally means setting | ||
312 | * an integer to 1/#GNUNET_YES/#GNUNET_OK. | ||
313 | * | ||
314 | * @param shortName short name of the option | ||
315 | * @param name long name of the option | ||
316 | * @param argumentHelp help text for the option argument | ||
317 | * @param description long help text for the option | ||
318 | * @param[out] val set to 1 if the option is present | ||
319 | */ | ||
320 | struct GNUNET_GETOPT_CommandLineOption | ||
321 | GNUNET_GETOPT_OPTION_SET_ONE (char shortName, | ||
322 | const char *name, | ||
323 | const char *description, | ||
324 | int *val) | ||
325 | { | ||
326 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
327 | .shortName = shortName, | ||
328 | .name = name, | ||
329 | .description = description, | ||
330 | .processor = &set_one, | ||
331 | .scls = (void *) val | ||
332 | }; | ||
333 | |||
334 | return clo; | ||
335 | } | ||
336 | |||
337 | |||
338 | /** | ||
219 | * Set an option of type 'char *' from the command line. | 339 | * Set an option of type 'char *' from the command line. |
220 | * A pointer to this function should be passed as part of the | 340 | * A pointer to this function should be passed as part of the |
221 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | 341 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options |
@@ -229,31 +349,174 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
229 | * @param value actual value of the option (a string) | 349 | * @param value actual value of the option (a string) |
230 | * @return #GNUNET_OK | 350 | * @return #GNUNET_OK |
231 | */ | 351 | */ |
232 | int | 352 | static int |
233 | GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 353 | set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
234 | void *scls, const char *option, const char *value) | 354 | void *scls, |
355 | const char *option, | ||
356 | const char *value) | ||
235 | { | 357 | { |
236 | char **val = scls; | 358 | char **val = scls; |
237 | 359 | ||
238 | GNUNET_assert (value != NULL); | 360 | GNUNET_assert (NULL != value); |
239 | GNUNET_free_non_null (*val); | 361 | GNUNET_free_non_null (*val); |
240 | *val = GNUNET_strdup (value); | 362 | *val = GNUNET_strdup (value); |
241 | return GNUNET_OK; | 363 | return GNUNET_OK; |
242 | } | 364 | } |
243 | 365 | ||
244 | 366 | ||
245 | int | 367 | /** |
246 | GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 368 | * Allow user to specify a string. |
247 | void *scls, const char *option, const char *value) | 369 | * |
370 | * @param shortName short name of the option | ||
371 | * @param name long name of the option | ||
372 | * @param argumentHelp help text for the option argument | ||
373 | * @param description long help text for the option | ||
374 | * @param[out] str set to the string | ||
375 | */ | ||
376 | struct GNUNET_GETOPT_CommandLineOption | ||
377 | GNUNET_GETOPT_OPTION_STRING (char shortName, | ||
378 | const char *name, | ||
379 | const char *argumentHelp, | ||
380 | const char *description, | ||
381 | char **str) | ||
382 | { | ||
383 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
384 | .shortName = shortName, | ||
385 | .name = name, | ||
386 | .argumentHelp = argumentHelp, | ||
387 | .description = description, | ||
388 | .require_argument = 1, | ||
389 | .processor = &set_string, | ||
390 | .scls = (void *) str | ||
391 | }; | ||
392 | |||
393 | return clo; | ||
394 | } | ||
395 | |||
396 | |||
397 | /** | ||
398 | * Define the '-L' log level option. Note that we do not check | ||
399 | * that the log level is valid here. | ||
400 | * | ||
401 | * @param[out] level set to the log level | ||
402 | */ | ||
403 | struct GNUNET_GETOPT_CommandLineOption | ||
404 | GNUNET_GETOPT_OPTION_LOGLEVEL (char **level) | ||
405 | { | ||
406 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
407 | .shortName = 'L', | ||
408 | .name = "log", | ||
409 | .argumentHelp = "LOGLEVEL", | ||
410 | .description = gettext_noop("configure logging to use LOGLEVEL"), | ||
411 | .require_argument = 1, | ||
412 | .processor = &set_string, | ||
413 | .scls = (void *) level | ||
414 | }; | ||
415 | |||
416 | return clo; | ||
417 | } | ||
418 | |||
419 | |||
420 | /** | ||
421 | * Set an option of type 'char *' from the command line with | ||
422 | * filename expansion a la #GNUNET_STRINGS_filename_expand(). | ||
423 | * | ||
424 | * @param ctx command line processing context | ||
425 | * @param scls additional closure (will point to the `char *`, | ||
426 | * which will be allocated) | ||
427 | * @param option name of the option | ||
428 | * @param value actual value of the option (a string) | ||
429 | * @return #GNUNET_OK | ||
430 | */ | ||
431 | static int | ||
432 | set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | ||
433 | void *scls, | ||
434 | const char *option, | ||
435 | const char *value) | ||
248 | { | 436 | { |
249 | char **val = scls; | 437 | char **val = scls; |
250 | 438 | ||
251 | GNUNET_assert (value != NULL); | 439 | GNUNET_assert (NULL != value); |
252 | GNUNET_free_non_null (*val); | 440 | GNUNET_free_non_null (*val); |
253 | *val = GNUNET_STRINGS_filename_expand (value); | 441 | *val = GNUNET_STRINGS_filename_expand (value); |
254 | return GNUNET_OK; | 442 | return GNUNET_OK; |
255 | } | 443 | } |
256 | 444 | ||
445 | |||
446 | /** | ||
447 | * Allow user to specify a filename (automatically path expanded). | ||
448 | * | ||
449 | * @param shortName short name of the option | ||
450 | * @param name long name of the option | ||
451 | * @param argumentHelp help text for the option argument | ||
452 | * @param description long help text for the option | ||
453 | * @param[out] str set to the string | ||
454 | */ | ||
455 | struct GNUNET_GETOPT_CommandLineOption | ||
456 | GNUNET_GETOPT_OPTION_FILENAME (char shortName, | ||
457 | const char *name, | ||
458 | const char *argumentHelp, | ||
459 | const char *description, | ||
460 | char **str) | ||
461 | { | ||
462 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
463 | .shortName = shortName, | ||
464 | .name = name, | ||
465 | .argumentHelp = argumentHelp, | ||
466 | .description = description, | ||
467 | .require_argument = 1, | ||
468 | .processor = &set_filename, | ||
469 | .scls = (void *) str | ||
470 | }; | ||
471 | |||
472 | return clo; | ||
473 | } | ||
474 | |||
475 | |||
476 | /** | ||
477 | * Allow user to specify log file name (-l option) | ||
478 | * | ||
479 | * @param[out] logfn set to the name of the logfile | ||
480 | */ | ||
481 | struct GNUNET_GETOPT_CommandLineOption | ||
482 | GNUNET_GETOPT_OPTION_LOGFILE (char **logfn) | ||
483 | { | ||
484 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
485 | .shortName = 'l', | ||
486 | .name = "logfile", | ||
487 | .argumentHelp = "FILENAME", | ||
488 | .description = gettext_noop ("configure logging to write logs to FILENAME"), | ||
489 | .require_argument = 1, | ||
490 | .processor = &set_filename, | ||
491 | .scls = (void *) logfn | ||
492 | }; | ||
493 | |||
494 | return clo; | ||
495 | } | ||
496 | |||
497 | |||
498 | /** | ||
499 | * Allow user to specify configuration file name (-c option) | ||
500 | * | ||
501 | * @param[out] fn set to the name of the configuration file | ||
502 | */ | ||
503 | struct GNUNET_GETOPT_CommandLineOption | ||
504 | GNUNET_GETOPT_OPTION_CFG_FILE (char **fn) | ||
505 | { | ||
506 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
507 | .shortName = 'c', | ||
508 | .name = "config", | ||
509 | .argumentHelp = "FILENAME", | ||
510 | .description = gettext_noop("use configuration file FILENAME"), | ||
511 | .require_argument = 1, | ||
512 | .processor = &set_filename, | ||
513 | .scls = (void *) fn | ||
514 | }; | ||
515 | |||
516 | return clo; | ||
517 | } | ||
518 | |||
519 | |||
257 | /** | 520 | /** |
258 | * Set an option of type 'unsigned long long' from the command line. | 521 | * Set an option of type 'unsigned long long' from the command line. |
259 | * A pointer to this function should be passed as part of the | 522 | * A pointer to this function should be passed as part of the |
@@ -267,15 +530,21 @@ GNUNET_GETOPT_set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ct | |||
267 | * @param value actual value of the option as a string. | 530 | * @param value actual value of the option as a string. |
268 | * @return #GNUNET_OK if parsing the value worked | 531 | * @return #GNUNET_OK if parsing the value worked |
269 | */ | 532 | */ |
270 | int | 533 | static int |
271 | GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 534 | set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
272 | void *scls, const char *option, const char *value) | 535 | void *scls, |
536 | const char *option, | ||
537 | const char *value) | ||
273 | { | 538 | { |
274 | unsigned long long *val = scls; | 539 | unsigned long long *val = scls; |
275 | 540 | ||
276 | if (1 != SSCANF (value, "%llu", val)) | 541 | if (1 != SSCANF (value, |
542 | "%llu", | ||
543 | val)) | ||
277 | { | 544 | { |
278 | FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option); | 545 | FPRINTF (stderr, |
546 | _("You must pass a number to the `%s' option.\n"), | ||
547 | option); | ||
279 | return GNUNET_SYSERR; | 548 | return GNUNET_SYSERR; |
280 | } | 549 | } |
281 | return GNUNET_OK; | 550 | return GNUNET_OK; |
@@ -283,6 +552,36 @@ GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
283 | 552 | ||
284 | 553 | ||
285 | /** | 554 | /** |
555 | * Allow user to specify an `unsigned long long` | ||
556 | * | ||
557 | * @param shortName short name of the option | ||
558 | * @param name long name of the option | ||
559 | * @param argumentHelp help text for the option argument | ||
560 | * @param description long help text for the option | ||
561 | * @param[out] val set to the value specified at the command line | ||
562 | */ | ||
563 | struct GNUNET_GETOPT_CommandLineOption | ||
564 | GNUNET_GETOPT_OPTION_SET_ULONG (char shortName, | ||
565 | const char *name, | ||
566 | const char *argumentHelp, | ||
567 | const char *description, | ||
568 | unsigned long long *val) | ||
569 | { | ||
570 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
571 | .shortName = shortName, | ||
572 | .name = name, | ||
573 | .argumentHelp = argumentHelp, | ||
574 | .description = description, | ||
575 | .require_argument = 1, | ||
576 | .processor = &set_ulong, | ||
577 | .scls = (void *) val | ||
578 | }; | ||
579 | |||
580 | return clo; | ||
581 | } | ||
582 | |||
583 | |||
584 | /** | ||
286 | * Set an option of type 'struct GNUNET_TIME_Relative' from the command line. | 585 | * Set an option of type 'struct GNUNET_TIME_Relative' from the command line. |
287 | * A pointer to this function should be passed as part of the | 586 | * A pointer to this function should be passed as part of the |
288 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | 587 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options |
@@ -295,9 +594,11 @@ GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
295 | * @param value actual value of the option as a string. | 594 | * @param value actual value of the option as a string. |
296 | * @return #GNUNET_OK if parsing the value worked | 595 | * @return #GNUNET_OK if parsing the value worked |
297 | */ | 596 | */ |
298 | int | 597 | static int |
299 | GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 598 | set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
300 | void *scls, const char *option, const char *value) | 599 | void *scls, |
600 | const char *option, | ||
601 | const char *value) | ||
301 | { | 602 | { |
302 | struct GNUNET_TIME_Relative *val = scls; | 603 | struct GNUNET_TIME_Relative *val = scls; |
303 | 604 | ||
@@ -305,7 +606,74 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex | |||
305 | GNUNET_STRINGS_fancy_time_to_relative (value, | 606 | GNUNET_STRINGS_fancy_time_to_relative (value, |
306 | val)) | 607 | val)) |
307 | { | 608 | { |
308 | FPRINTF (stderr, _("You must pass relative time to the `%s' option.\n"), option); | 609 | FPRINTF (stderr, |
610 | _("You must pass relative time to the `%s' option.\n"), | ||
611 | option); | ||
612 | return GNUNET_SYSERR; | ||
613 | } | ||
614 | return GNUNET_OK; | ||
615 | } | ||
616 | |||
617 | |||
618 | /** | ||
619 | * Allow user to specify a `struct GNUNET_TIME_Relative` | ||
620 | * (using human-readable "fancy" time). | ||
621 | * | ||
622 | * @param shortName short name of the option | ||
623 | * @param name long name of the option | ||
624 | * @param argumentHelp help text for the option argument | ||
625 | * @param description long help text for the option | ||
626 | * @param[out] val set to the time specified at the command line | ||
627 | */ | ||
628 | struct GNUNET_GETOPT_CommandLineOption | ||
629 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName, | ||
630 | const char *name, | ||
631 | const char *argumentHelp, | ||
632 | const char *description, | ||
633 | struct GNUNET_TIME_Relative *val) | ||
634 | { | ||
635 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
636 | .shortName = shortName, | ||
637 | .name = name, | ||
638 | .argumentHelp = argumentHelp, | ||
639 | .description = description, | ||
640 | .require_argument = 1, | ||
641 | .processor = &set_relative_time, | ||
642 | .scls = (void *) val | ||
643 | }; | ||
644 | |||
645 | return clo; | ||
646 | } | ||
647 | |||
648 | |||
649 | /** | ||
650 | * Set an option of type 'struct GNUNET_TIME_Absolute' from the command line. | ||
651 | * A pointer to this function should be passed as part of the | ||
652 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | ||
653 | * of this type. It should be followed by a pointer to a value of | ||
654 | * type 'struct GNUNET_TIME_Absolute'. | ||
655 | * | ||
656 | * @param ctx command line processing context | ||
657 | * @param scls additional closure (will point to the `struct GNUNET_TIME_Absolute`) | ||
658 | * @param option name of the option | ||
659 | * @param value actual value of the option as a string. | ||
660 | * @return #GNUNET_OK if parsing the value worked | ||
661 | */ | ||
662 | static int | ||
663 | set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | ||
664 | void *scls, | ||
665 | const char *option, | ||
666 | const char *value) | ||
667 | { | ||
668 | struct GNUNET_TIME_Absolute *val = scls; | ||
669 | |||
670 | if (GNUNET_OK != | ||
671 | GNUNET_STRINGS_fancy_time_to_absolute (value, | ||
672 | val)) | ||
673 | { | ||
674 | FPRINTF (stderr, | ||
675 | _("You must pass absolute time to the `%s' option.\n"), | ||
676 | option); | ||
309 | return GNUNET_SYSERR; | 677 | return GNUNET_SYSERR; |
310 | } | 678 | } |
311 | return GNUNET_OK; | 679 | return GNUNET_OK; |
@@ -313,6 +681,37 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex | |||
313 | 681 | ||
314 | 682 | ||
315 | /** | 683 | /** |
684 | * Allow user to specify a `struct GNUNET_TIME_Absolute` | ||
685 | * (using human-readable "fancy" time). | ||
686 | * | ||
687 | * @param shortName short name of the option | ||
688 | * @param name long name of the option | ||
689 | * @param argumentHelp help text for the option argument | ||
690 | * @param description long help text for the option | ||
691 | * @param[out] val set to the time specified at the command line | ||
692 | */ | ||
693 | struct GNUNET_GETOPT_CommandLineOption | ||
694 | GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName, | ||
695 | const char *name, | ||
696 | const char *argumentHelp, | ||
697 | const char *description, | ||
698 | struct GNUNET_TIME_Absolute *val) | ||
699 | { | ||
700 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
701 | .shortName = shortName, | ||
702 | .name = name, | ||
703 | .argumentHelp = argumentHelp, | ||
704 | .description = description, | ||
705 | .require_argument = 1, | ||
706 | .processor = &set_absolute_time, | ||
707 | .scls = (void *) val | ||
708 | }; | ||
709 | |||
710 | return clo; | ||
711 | } | ||
712 | |||
713 | |||
714 | /** | ||
316 | * Set an option of type 'unsigned int' from the command line. | 715 | * Set an option of type 'unsigned int' from the command line. |
317 | * A pointer to this function should be passed as part of the | 716 | * A pointer to this function should be passed as part of the |
318 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | 717 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options |
@@ -325,19 +724,172 @@ GNUNET_GETOPT_set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContex | |||
325 | * @param value actual value of the option as a string. | 724 | * @param value actual value of the option as a string. |
326 | * @return #GNUNET_OK if parsing the value worked | 725 | * @return #GNUNET_OK if parsing the value worked |
327 | */ | 726 | */ |
328 | int | 727 | static int |
329 | GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 728 | set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
330 | void *scls, const char *option, const char *value) | 729 | void *scls, |
730 | const char *option, | ||
731 | const char *value) | ||
331 | { | 732 | { |
332 | unsigned int *val = scls; | 733 | unsigned int *val = scls; |
333 | 734 | ||
334 | if (1 != SSCANF (value, "%u", val)) | 735 | if (1 != SSCANF (value, |
736 | "%u", | ||
737 | val)) | ||
335 | { | 738 | { |
336 | FPRINTF (stderr, _("You must pass a number to the `%s' option.\n"), option); | 739 | FPRINTF (stderr, |
740 | _("You must pass a number to the `%s' option.\n"), | ||
741 | option); | ||
337 | return GNUNET_SYSERR; | 742 | return GNUNET_SYSERR; |
338 | } | 743 | } |
339 | return GNUNET_OK; | 744 | return GNUNET_OK; |
340 | } | 745 | } |
341 | 746 | ||
342 | 747 | ||
748 | /** | ||
749 | * Allow user to specify an unsigned integer. | ||
750 | * | ||
751 | * @param shortName short name of the option | ||
752 | * @param name long name of the option | ||
753 | * @param argumentHelp help text for the option argument | ||
754 | * @param description long help text for the option | ||
755 | * @param[out] val set to the value specified at the command line | ||
756 | */ | ||
757 | struct GNUNET_GETOPT_CommandLineOption | ||
758 | GNUNET_GETOPT_OPTION_SET_UINT (char shortName, | ||
759 | const char *name, | ||
760 | const char *argumentHelp, | ||
761 | const char *description, | ||
762 | unsigned int *val) | ||
763 | { | ||
764 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
765 | .shortName = shortName, | ||
766 | .name = name, | ||
767 | .argumentHelp = argumentHelp, | ||
768 | .description = description, | ||
769 | .require_argument = 1, | ||
770 | .processor = &set_uint, | ||
771 | .scls = (void *) val | ||
772 | }; | ||
773 | |||
774 | return clo; | ||
775 | } | ||
776 | |||
777 | |||
778 | /** | ||
779 | * Closure for #set_base32(). | ||
780 | */ | ||
781 | struct Base32Context | ||
782 | { | ||
783 | /** | ||
784 | * Value to initialize (already allocated) | ||
785 | */ | ||
786 | void *val; | ||
787 | |||
788 | /** | ||
789 | * Number of bytes expected for @e val. | ||
790 | */ | ||
791 | size_t val_size; | ||
792 | }; | ||
793 | |||
794 | |||
795 | /** | ||
796 | * Set an option of type 'unsigned int' from the command line. | ||
797 | * A pointer to this function should be passed as part of the | ||
798 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | ||
799 | * of this type. It should be followed by a pointer to a value of | ||
800 | * type 'unsigned int'. | ||
801 | * | ||
802 | * @param ctx command line processing context | ||
803 | * @param scls additional closure (will point to the 'unsigned int') | ||
804 | * @param option name of the option | ||
805 | * @param value actual value of the option as a string. | ||
806 | * @return #GNUNET_OK if parsing the value worked | ||
807 | */ | ||
808 | static int | ||
809 | set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | ||
810 | void *scls, | ||
811 | const char *option, | ||
812 | const char *value) | ||
813 | { | ||
814 | struct Base32Context *bc = scls; | ||
815 | |||
816 | if (GNUNET_OK != | ||
817 | GNUNET_STRINGS_string_to_data (value, | ||
818 | strlen (value), | ||
819 | bc->val, | ||
820 | bc->val_size)) | ||
821 | { | ||
822 | fprintf (stderr, | ||
823 | _("Argument `%s' malformed. Expected base32 (Crockford) encoded value.\n"), | ||
824 | option); | ||
825 | return GNUNET_SYSERR; | ||
826 | } | ||
827 | return GNUNET_OK; | ||
828 | } | ||
829 | |||
830 | |||
831 | /** | ||
832 | * Helper function to clean up after | ||
833 | * #GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE. | ||
834 | * | ||
835 | * @param cls value to GNUNET_free() | ||
836 | */ | ||
837 | static void | ||
838 | free_bc (void *cls) | ||
839 | { | ||
840 | GNUNET_free (cls); | ||
841 | } | ||
842 | |||
843 | |||
844 | /** | ||
845 | * Allow user to specify a binary value using Crockford | ||
846 | * Base32 encoding. | ||
847 | * | ||
848 | * @param shortName short name of the option | ||
849 | * @param name long name of the option | ||
850 | * @param argumentHelp help text for the option argument | ||
851 | * @param description long help text for the option | ||
852 | * @param[out] val binary value decoded from Crockford Base32-encoded argument | ||
853 | * @param val_size size of @a val in bytes | ||
854 | */ | ||
855 | struct GNUNET_GETOPT_CommandLineOption | ||
856 | GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName, | ||
857 | const char *name, | ||
858 | const char *argumentHelp, | ||
859 | const char *description, | ||
860 | void *val, | ||
861 | size_t val_size) | ||
862 | { | ||
863 | struct Base32Context *bc = GNUNET_new (struct Base32Context); | ||
864 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
865 | .shortName = shortName, | ||
866 | .name = name, | ||
867 | .argumentHelp = argumentHelp, | ||
868 | .description = description, | ||
869 | .require_argument = 1, | ||
870 | .processor = &set_base32, | ||
871 | .cleaner = &free_bc, | ||
872 | .scls = (void *) bc | ||
873 | }; | ||
874 | |||
875 | bc->val = val; | ||
876 | bc->val_size = val_size; | ||
877 | return clo; | ||
878 | } | ||
879 | |||
880 | |||
881 | /** | ||
882 | * Make the given option mandatory. | ||
883 | * | ||
884 | * @param opt option to modify | ||
885 | * @return @a opt with the mandatory flag set. | ||
886 | */ | ||
887 | struct GNUNET_GETOPT_CommandLineOption | ||
888 | GNUNET_GETOPT_OPTION_MANDATORY (struct GNUNET_GETOPT_CommandLineOption opt) | ||
889 | { | ||
890 | opt.option_mandatory = 1; | ||
891 | return opt; | ||
892 | } | ||
893 | |||
894 | |||
343 | /* end of getopt_helpers.c */ | 895 | /* end of getopt_helpers.c */ |
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 7ec7162f1..2beb772a9 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c | |||
@@ -223,34 +223,48 @@ run (void *cls, | |||
223 | int | 223 | int |
224 | main (int argc, char *const *argv) | 224 | main (int argc, char *const *argv) |
225 | { | 225 | { |
226 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 226 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
227 | { 'f', "filename", NULL, | 227 | GNUNET_GETOPT_OPTION_SET_ONE ('f', |
228 | gettext_noop ("obtain option of value as a filename (with $-expansion)"), | 228 | "filename", |
229 | 0, &GNUNET_GETOPT_set_one, &is_filename }, | 229 | gettext_noop ("obtain option of value as a filename (with $-expansion)"), |
230 | { 's', "section", "SECTION", | 230 | &is_filename), |
231 | gettext_noop ("name of the section to access"), | 231 | GNUNET_GETOPT_OPTION_STRING ('s', |
232 | 1, &GNUNET_GETOPT_set_string, §ion }, | 232 | "section", |
233 | { 'o', "option", "OPTION", | 233 | "SECTION", |
234 | gettext_noop ("name of the option to access"), | 234 | gettext_noop ("name of the section to access"), |
235 | 1, &GNUNET_GETOPT_set_string, &option }, | 235 | §ion), |
236 | { 'V', "value", "VALUE", | 236 | GNUNET_GETOPT_OPTION_STRING ('o', |
237 | gettext_noop ("value to set"), | 237 | "option", |
238 | 1, &GNUNET_GETOPT_set_string, &value }, | 238 | "OPTION", |
239 | { 'S', "list-sections", NULL, | 239 | gettext_noop ("name of the option to access"), |
240 | gettext_noop ("print available configuration sections"), | 240 | &option), |
241 | 0, &GNUNET_GETOPT_set_one, &list_sections }, | 241 | GNUNET_GETOPT_OPTION_STRING ('V', |
242 | { 'w', "rewrite", NULL, | 242 | "value", |
243 | gettext_noop ("write configuration file that only contains delta to defaults"), | 243 | "VALUE", |
244 | 0, &GNUNET_GETOPT_set_one, &rewrite }, | 244 | gettext_noop ("value to set"), |
245 | &value), | ||
246 | GNUNET_GETOPT_OPTION_SET_ONE ('S', | ||
247 | "list-sections", | ||
248 | gettext_noop ("print available configuration sections"), | ||
249 | &list_sections), | ||
250 | GNUNET_GETOPT_OPTION_SET_ONE ('w', | ||
251 | "rewrite", | ||
252 | gettext_noop ("write configuration file that only contains delta to defaults"), | ||
253 | &rewrite), | ||
245 | GNUNET_GETOPT_OPTION_END | 254 | GNUNET_GETOPT_OPTION_END |
246 | }; | 255 | }; |
247 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 256 | if (GNUNET_OK != |
257 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
258 | &argc, &argv)) | ||
248 | return 2; | 259 | return 2; |
249 | 260 | ||
250 | ret = (GNUNET_OK == | 261 | ret = (GNUNET_OK == |
251 | GNUNET_PROGRAM_run (argc, argv, "gnunet-config [OPTIONS]", | 262 | GNUNET_PROGRAM_run (argc, |
263 | argv, | ||
264 | "gnunet-config [OPTIONS]", | ||
252 | gettext_noop ("Manipulate GNUnet configuration files"), | 265 | gettext_noop ("Manipulate GNUnet configuration files"), |
253 | options, &run, NULL)) ? 0 : ret; | 266 | options, |
267 | &run, NULL)) ? 0 : ret; | ||
254 | GNUNET_free ((void*) argv); | 268 | GNUNET_free ((void*) argv); |
255 | return ret; | 269 | return ret; |
256 | } | 270 | } |
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index ddfd9b1c3..732228b52 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -41,7 +41,7 @@ static int list_keys; | |||
41 | /** | 41 | /** |
42 | * Flag for listing public key. | 42 | * Flag for listing public key. |
43 | */ | 43 | */ |
44 | static int list_keys_count; | 44 | static unsigned int list_keys_count; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Flag for printing public key. | 47 | * Flag for printing public key. |
@@ -406,36 +406,50 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
406 | * @return 0 ok, 1 on error | 406 | * @return 0 ok, 1 on error |
407 | */ | 407 | */ |
408 | int | 408 | int |
409 | main (int argc, char *const *argv) | 409 | main (int argc, |
410 | char *const *argv) | ||
410 | { | 411 | { |
411 | list_keys_count = UINT32_MAX; | 412 | list_keys_count = UINT32_MAX; |
412 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 413 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
413 | { 'i', "iterate", "FILE", | 414 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
414 | gettext_noop ("list keys included in a file (for testing)"), | 415 | "iterate", |
415 | 0, &GNUNET_GETOPT_set_one, &list_keys }, | 416 | gettext_noop ("list keys included in a file (for testing)"), |
416 | { 'e', "end=", "COUNT", | 417 | &list_keys), |
417 | gettext_noop ("number of keys to list included in a file (for testing)"), | 418 | GNUNET_GETOPT_OPTION_SET_UINT ('e', |
418 | 1, &GNUNET_GETOPT_set_uint, &list_keys_count }, | 419 | "end=", |
419 | { 'g', "generate-keys", "COUNT", | 420 | "COUNT", |
420 | gettext_noop ("create COUNT public-private key pairs (for testing)"), | 421 | gettext_noop ("number of keys to list included in a file (for testing)"), |
421 | 1, &GNUNET_GETOPT_set_uint, &make_keys }, | 422 | &list_keys_count), |
422 | { 'p', "print-public-key", NULL, | 423 | GNUNET_GETOPT_OPTION_SET_UINT ('g', |
423 | gettext_noop ("print the public key in ASCII format"), | 424 | "generate-keys", |
424 | 0, &GNUNET_GETOPT_set_one, &print_public_key }, | 425 | "COUNT", |
425 | { 'E', "examples", NULL, | 426 | gettext_noop ("create COUNT public-private key pairs (for testing)"), |
426 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), | 427 | &make_keys), |
427 | 0, &GNUNET_GETOPT_set_one, &print_examples_flag }, | 428 | GNUNET_GETOPT_OPTION_SET_ONE ('p', |
429 | "print-public-key", | ||
430 | gettext_noop ("print the public key in ASCII format"), | ||
431 | &print_public_key), | ||
432 | GNUNET_GETOPT_OPTION_SET_ONE ('E', | ||
433 | "examples", | ||
434 | gettext_noop ("print examples of ECC operations (used for compatibility testing)"), | ||
435 | &print_examples_flag), | ||
428 | GNUNET_GETOPT_OPTION_END | 436 | GNUNET_GETOPT_OPTION_END |
429 | }; | 437 | }; |
430 | int ret; | 438 | int ret; |
431 | 439 | ||
432 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 440 | if (GNUNET_OK != |
441 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
442 | &argc, &argv)) | ||
433 | return 2; | 443 | return 2; |
434 | 444 | ||
435 | ret = (GNUNET_OK == | 445 | ret = (GNUNET_OK == |
436 | GNUNET_PROGRAM_run (argc, argv, "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]", | 446 | GNUNET_PROGRAM_run (argc, |
447 | argv, | ||
448 | "gnunet-ecc [OPTIONS] keyfile [VANITY_PREFIX]", | ||
437 | gettext_noop ("Manipulate GNUnet private ECC key files"), | 449 | gettext_noop ("Manipulate GNUnet private ECC key files"), |
438 | options, &run, NULL)) ? 0 : 1; | 450 | options, |
451 | &run, | ||
452 | NULL)) ? 0 : 1; | ||
439 | GNUNET_free ((void*) argv); | 453 | GNUNET_free ((void*) argv); |
440 | return ret; | 454 | return ret; |
441 | } | 455 | } |
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index e84a2332f..563cf9fce 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c | |||
@@ -144,10 +144,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
144 | int | 144 | int |
145 | main (int argc, char *const *argv) | 145 | main (int argc, char *const *argv) |
146 | { | 146 | { |
147 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 147 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
148 | { 'r', "reverse", NULL, | 148 | GNUNET_GETOPT_OPTION_SET_ONE ('r', |
149 | gettext_noop ("perform a reverse lookup"), | 149 | "reverse", |
150 | 0, &GNUNET_GETOPT_set_one, &reverse }, | 150 | gettext_noop ("perform a reverse lookup"), |
151 | &reverse), | ||
151 | GNUNET_GETOPT_OPTION_END | 152 | GNUNET_GETOPT_OPTION_END |
152 | }; | 153 | }; |
153 | int ret; | 154 | int ret; |
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c index ab0cf92e0..7c73cfe1e 100644 --- a/src/util/gnunet-scrypt.c +++ b/src/util/gnunet-scrypt.c | |||
@@ -307,21 +307,30 @@ run (void *cls, | |||
307 | * @return 0 ok, 1 on error | 307 | * @return 0 ok, 1 on error |
308 | */ | 308 | */ |
309 | int | 309 | int |
310 | main (int argc, char *const *argv) | 310 | main (int argc, |
311 | char *const *argv) | ||
311 | { | 312 | { |
312 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 313 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
313 | { 'b', "bits", "BITS", | 314 | GNUNET_GETOPT_OPTION_SET_ULONG ('b', |
314 | gettext_noop ("number of bits to require for the proof of work"), | 315 | "bits", |
315 | 1, &GNUNET_GETOPT_set_ulong, &nse_work_required }, | 316 | "BITS", |
316 | { 'k', "keyfile", "FILE", | 317 | gettext_noop ("number of bits to require for the proof of work"), |
317 | gettext_noop ("file with private key, otherwise default is used"), | 318 | &nse_work_required), |
318 | 1, &GNUNET_GETOPT_set_filename, &pkfn }, | 319 | GNUNET_GETOPT_OPTION_FILENAME ('k', |
319 | { 'o', "outfile", "FILE", | 320 | "keyfile", |
320 | gettext_noop ("file with proof of work, otherwise default is used"), | 321 | "FILE", |
321 | 1, &GNUNET_GETOPT_set_filename, &pwfn }, | 322 | gettext_noop ("file with private key, otherwise default is used"), |
322 | { 't', "timeout", "TIME", | 323 | &pkfn), |
323 | gettext_noop ("time to wait between calculations"), | 324 | GNUNET_GETOPT_OPTION_FILENAME ('o', |
324 | 1, &GNUNET_GETOPT_set_relative_time, &proof_find_delay }, | 325 | "outfile", |
326 | "FILE", | ||
327 | gettext_noop ("file with proof of work, otherwise default is used"), | ||
328 | &pwfn), | ||
329 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
330 | "timeout", | ||
331 | "TIME", | ||
332 | gettext_noop ("time to wait between calculations"), | ||
333 | &proof_find_delay), | ||
325 | GNUNET_GETOPT_OPTION_END | 334 | GNUNET_GETOPT_OPTION_END |
326 | }; | 335 | }; |
327 | int ret; | 336 | int ret; |
@@ -334,7 +343,9 @@ main (int argc, char *const *argv) | |||
334 | GNUNET_PROGRAM_run (argc, argv, | 343 | GNUNET_PROGRAM_run (argc, argv, |
335 | "gnunet-scrypt [OPTIONS] prooffile", | 344 | "gnunet-scrypt [OPTIONS] prooffile", |
336 | gettext_noop ("Manipulate GNUnet proof of work files"), | 345 | gettext_noop ("Manipulate GNUnet proof of work files"), |
337 | options, &run, NULL)) ? 0 : 1; | 346 | options, |
347 | &run, | ||
348 | NULL)) ? 0 : 1; | ||
338 | GNUNET_free ((void*) argv); | 349 | GNUNET_free ((void*) argv); |
339 | GNUNET_free_non_null (pwfn); | 350 | GNUNET_free_non_null (pwfn); |
340 | return ret; | 351 | return ret; |
diff --git a/src/util/service_new.c b/src/util/service_new.c index 9c0ee539b..b4d03c17c 100644 --- a/src/util/service_new.c +++ b/src/util/service_new.c | |||
@@ -1723,9 +1723,10 @@ GNUNET_SERVICE_ruN_ (int argc, | |||
1723 | 1723 | ||
1724 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { | 1724 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { |
1725 | GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename), | 1725 | GNUNET_GETOPT_OPTION_CFG_FILE (&opt_cfg_filename), |
1726 | {'d', "daemonize", NULL, | 1726 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
1727 | gettext_noop ("do daemonize (detach from terminal)"), 0, | 1727 | "daemonize", |
1728 | GNUNET_GETOPT_set_one, &do_daemonize}, | 1728 | gettext_noop ("do daemonize (detach from terminal)"), |
1729 | &do_daemonize), | ||
1729 | GNUNET_GETOPT_OPTION_HELP (NULL), | 1730 | GNUNET_GETOPT_OPTION_HELP (NULL), |
1730 | GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), | 1731 | GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev), |
1731 | GNUNET_GETOPT_OPTION_LOGFILE (&logfile), | 1732 | GNUNET_GETOPT_OPTION_LOGFILE (&logfile), |
diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c index 8e578640d..13cedd7f5 100644 --- a/src/util/test_getopt.c +++ b/src/util/test_getopt.c | |||
@@ -136,13 +136,16 @@ testLogOpts () | |||
136 | GNUNET_GETOPT_OPTION_END | 136 | GNUNET_GETOPT_OPTION_END |
137 | }; | 137 | }; |
138 | 138 | ||
139 | if (5 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 5, myargv)) | 139 | if (5 != GNUNET_GETOPT_run ("test_getopt", |
140 | logoptionlist, | ||
141 | 5, myargv)) | ||
140 | { | 142 | { |
141 | GNUNET_break (0); | 143 | GNUNET_break (0); |
142 | return 1; | 144 | return 1; |
143 | } | 145 | } |
144 | GNUNET_assert (fn != NULL); | 146 | GNUNET_assert (NULL != fn); |
145 | if ((0 != strcmp (level, "WARNING")) || (0 != strcmp (fn, "filename"))) | 147 | if ( (0 != strcmp (level, "WARNING")) || |
148 | (NULL == strstr (fn, "/filename")) ) | ||
146 | { | 149 | { |
147 | GNUNET_break (0); | 150 | GNUNET_break (0); |
148 | GNUNET_free (level); | 151 | GNUNET_free (level); |
@@ -170,21 +173,35 @@ testFlagNum () | |||
170 | unsigned long long lnum = 0; | 173 | unsigned long long lnum = 0; |
171 | 174 | ||
172 | const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = { | 175 | const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = { |
173 | {'f', "--flag", NULL, "helptext", 0, &GNUNET_GETOPT_set_one, | 176 | GNUNET_GETOPT_OPTION_SET_ONE ('f', |
174 | (void *) &flag}, | 177 | "--flag", |
175 | {'n', "--num", "ARG", "helptext", 1, &GNUNET_GETOPT_set_uint, | 178 | "helptext", |
176 | (void *) &num}, | 179 | &flag), |
177 | {'N', "--lnum", "ARG", "helptext", 1, &GNUNET_GETOPT_set_ulong, | 180 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
178 | (void *) &lnum}, | 181 | "--num", |
182 | "ARG", | ||
183 | "helptext", | ||
184 | &num), | ||
185 | GNUNET_GETOPT_OPTION_SET_ULONG ('N', | ||
186 | "--lnum", | ||
187 | "ARG", | ||
188 | "helptext", | ||
189 | &lnum), | ||
179 | GNUNET_GETOPT_OPTION_END | 190 | GNUNET_GETOPT_OPTION_END |
180 | }; | 191 | }; |
181 | 192 | ||
182 | if (6 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 6, myargv)) | 193 | if (6 != |
194 | GNUNET_GETOPT_run ("test_getopt", | ||
195 | logoptionlist, | ||
196 | 6, | ||
197 | myargv)) | ||
183 | { | 198 | { |
184 | GNUNET_break (0); | 199 | GNUNET_break (0); |
185 | return 1; | 200 | return 1; |
186 | } | 201 | } |
187 | if ((1 != flag) || (42 != num) || (42 != lnum)) | 202 | if ( (1 != flag) || |
203 | (42 != num) || | ||
204 | (42 != lnum)) | ||
188 | { | 205 | { |
189 | GNUNET_break (0); | 206 | GNUNET_break (0); |
190 | return 1; | 207 | return 1; |
@@ -198,7 +215,9 @@ main (int argc, char *argv[]) | |||
198 | { | 215 | { |
199 | int errCnt = 0; | 216 | int errCnt = 0; |
200 | 217 | ||
201 | GNUNET_log_setup ("test_getopt", "WARNING", NULL); | 218 | GNUNET_log_setup ("test_getopt", |
219 | "WARNING", | ||
220 | NULL); | ||
202 | /* suppress output from -h, -v options */ | 221 | /* suppress output from -h, -v options */ |
203 | #ifndef MINGW | 222 | #ifndef MINGW |
204 | GNUNET_break (0 == CLOSE (1)); | 223 | GNUNET_break (0 == CLOSE (1)); |
diff --git a/src/util/test_program.c b/src/util/test_program.c index 669cee7bd..d206952af 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c | |||
@@ -24,37 +24,19 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_util_lib.h" | 25 | #include "gnunet_util_lib.h" |
26 | 26 | ||
27 | static int setme1, setme2; | 27 | |
28 | 28 | static int setme1; | |
29 | static struct GNUNET_GETOPT_CommandLineOption options1[] = { | 29 | |
30 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1}, | 30 | static int setme2; |
31 | GNUNET_GETOPT_OPTION_END | 31 | |
32 | }; | ||
33 | |||
34 | static struct GNUNET_GETOPT_CommandLineOption options2[] = { | ||
35 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1}, | ||
36 | {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}, | ||
37 | GNUNET_GETOPT_OPTION_END | ||
38 | }; | ||
39 | |||
40 | static struct GNUNET_GETOPT_CommandLineOption options3[] = { | ||
41 | {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1}, | ||
42 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}, | ||
43 | GNUNET_GETOPT_OPTION_END | ||
44 | }; | ||
45 | |||
46 | static struct GNUNET_GETOPT_CommandLineOption options4[] = { | ||
47 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1}, | ||
48 | {'n', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}, | ||
49 | GNUNET_GETOPT_OPTION_END | ||
50 | }; | ||
51 | 32 | ||
52 | /** | 33 | /** |
53 | * Main function that will be run. | 34 | * Main function that will be run. |
54 | */ | 35 | */ |
55 | |||
56 | static void | 36 | static void |
57 | runner (void *cls, char *const *args, const char *cfgfile, | 37 | runner (void *cls, |
38 | char *const *args, | ||
39 | const char *cfgfile, | ||
58 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 40 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
59 | { | 41 | { |
60 | int *ok = cls; | 42 | int *ok = cls; |
@@ -62,21 +44,16 @@ runner (void *cls, char *const *args, const char *cfgfile, | |||
62 | GNUNET_assert (setme1 == 1); | 44 | GNUNET_assert (setme1 == 1); |
63 | GNUNET_assert (0 == strcmp (args[0], "extra")); | 45 | GNUNET_assert (0 == strcmp (args[0], "extra")); |
64 | GNUNET_assert (args[1] == NULL); | 46 | GNUNET_assert (args[1] == NULL); |
65 | GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf")); | 47 | GNUNET_assert (NULL != strstr (cfgfile, "/test_program_data.conf")); |
66 | |||
67 | *ok = 0; | 48 | *ok = 0; |
68 | } | 49 | } |
69 | 50 | ||
70 | /** | 51 | |
71 | * Main method, starts scheduler with task1, | 52 | int |
72 | * checks that "ok" is correct at the end. | 53 | main (int argc, char *argv[]) |
73 | */ | ||
74 | static int | ||
75 | check () | ||
76 | { | 54 | { |
77 | int ok = 1; | 55 | int ok = 1; |
78 | 56 | char *const argvx[] = { | |
79 | char *const argv[] = { | ||
80 | "test_program", | 57 | "test_program", |
81 | "-c", | 58 | "-c", |
82 | "test_program_data.conf", | 59 | "test_program_data.conf", |
@@ -86,33 +63,75 @@ check () | |||
86 | "extra", | 63 | "extra", |
87 | NULL | 64 | NULL |
88 | }; | 65 | }; |
66 | struct GNUNET_GETOPT_CommandLineOption options1[] = { | ||
67 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
68 | "name", | ||
69 | "description", | ||
70 | &setme1), | ||
71 | GNUNET_GETOPT_OPTION_END | ||
72 | }; | ||
73 | struct GNUNET_GETOPT_CommandLineOption options2[] = { | ||
74 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
75 | "name", | ||
76 | "description", | ||
77 | &setme1), | ||
78 | GNUNET_GETOPT_OPTION_SET_ONE ('N', | ||
79 | "number", | ||
80 | "description", | ||
81 | &setme2), | ||
82 | GNUNET_GETOPT_OPTION_END | ||
83 | }; | ||
84 | struct GNUNET_GETOPT_CommandLineOption options3[] = { | ||
85 | GNUNET_GETOPT_OPTION_SET_ONE ('N', | ||
86 | "number", | ||
87 | "description", | ||
88 | &setme1), | ||
89 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
90 | "name", | ||
91 | "description", | ||
92 | &setme2), | ||
93 | GNUNET_GETOPT_OPTION_END | ||
94 | }; | ||
95 | struct GNUNET_GETOPT_CommandLineOption options4[] = { | ||
96 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
97 | "name", | ||
98 | "description", | ||
99 | &setme1), | ||
100 | GNUNET_GETOPT_OPTION_SET_ONE ('n', | ||
101 | "name", | ||
102 | "description", | ||
103 | &setme2), | ||
104 | GNUNET_GETOPT_OPTION_END | ||
105 | }; | ||
89 | 106 | ||
107 | |||
108 | GNUNET_log_setup ("test_program", | ||
109 | "WARNING", | ||
110 | NULL); | ||
90 | GNUNET_assert (GNUNET_OK == | 111 | GNUNET_assert (GNUNET_OK == |
91 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", | 112 | GNUNET_PROGRAM_run (7, argvx, |
92 | options1, &runner, &ok)); | 113 | "test_program", |
114 | "A test", | ||
115 | options1, | ||
116 | &runner, &ok)); | ||
93 | 117 | ||
94 | GNUNET_assert (GNUNET_OK == | 118 | GNUNET_assert (GNUNET_OK == |
95 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", | 119 | GNUNET_PROGRAM_run (7, argvx, |
96 | options2, &runner, &ok)); | 120 | "test_program", "A test", |
121 | options2, | ||
122 | &runner, &ok)); | ||
97 | GNUNET_assert (GNUNET_OK == | 123 | GNUNET_assert (GNUNET_OK == |
98 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", | 124 | GNUNET_PROGRAM_run (7, argvx, |
99 | options3, &runner, &ok)); | 125 | "test_program", "A test", |
126 | options3, | ||
127 | &runner, &ok)); | ||
100 | GNUNET_assert (GNUNET_OK == | 128 | GNUNET_assert (GNUNET_OK == |
101 | GNUNET_PROGRAM_run (7, argv, "test_program", "A test", | 129 | GNUNET_PROGRAM_run (7, argvx, |
102 | options4, &runner, &ok)); | 130 | "test_program", "A test", |
131 | options4, | ||
132 | &runner, &ok)); | ||
103 | 133 | ||
104 | return ok; | 134 | return ok; |
105 | } | 135 | } |
106 | 136 | ||
107 | int | ||
108 | main (int argc, char *argv[]) | ||
109 | { | ||
110 | int ret = 0; | ||
111 | |||
112 | GNUNET_log_setup ("test_program", "WARNING", NULL); | ||
113 | ret += check (); | ||
114 | |||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | /* end of test_program.c */ | 137 | /* end of test_program.c */ |
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c index 2e7daf7f7..0adbd5c96 100644 --- a/src/vpn/gnunet-vpn.c +++ b/src/vpn/gnunet-vpn.c | |||
@@ -78,7 +78,7 @@ static int udp; | |||
78 | /** | 78 | /** |
79 | * Selected level of verbosity. | 79 | * Selected level of verbosity. |
80 | */ | 80 | */ |
81 | static int verbosity; | 81 | static unsigned int verbosity; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Global return value. | 84 | * Global return value. |
@@ -286,33 +286,53 @@ run (void *cls, | |||
286 | int | 286 | int |
287 | main (int argc, char *const *argv) | 287 | main (int argc, char *const *argv) |
288 | { | 288 | { |
289 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 289 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
290 | {'4', "ipv4", NULL, | 290 | GNUNET_GETOPT_OPTION_SET_ONE ('4', |
291 | gettext_noop ("request that result should be an IPv4 address"), | 291 | "ipv4", |
292 | 0, &GNUNET_GETOPT_set_one, &ipv4}, | 292 | gettext_noop ("request that result should be an IPv4 address"), |
293 | {'6', "ipv6", NULL, | 293 | &ipv4), |
294 | gettext_noop ("request that result should be an IPv6 address"), | 294 | |
295 | 0, &GNUNET_GETOPT_set_one, &ipv6}, | 295 | GNUNET_GETOPT_OPTION_SET_ONE ('6', |
296 | {'d', "duration", "TIME", | 296 | "ipv6", |
297 | gettext_noop ("how long should the mapping be valid for new tunnels?"), | 297 | gettext_noop ("request that result should be an IPv6 address"), |
298 | 1, &GNUNET_GETOPT_set_relative_time, &duration}, | 298 | &ipv6), |
299 | {'i', "ip", "IP", | 299 | |
300 | gettext_noop ("destination IP for the tunnel"), | 300 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('d', |
301 | 1, &GNUNET_GETOPT_set_string, &target_ip}, | 301 | "duration", |
302 | {'p', "peer", "PEERID", | 302 | "TIME", |
303 | gettext_noop ("peer offering the service we would like to access"), | 303 | gettext_noop ("how long should the mapping be valid for new tunnels?"), |
304 | 1, &GNUNET_GETOPT_set_string, &peer_id}, | 304 | &duration), |
305 | {'s', "service", "NAME", | 305 | |
306 | gettext_noop ("name of the service we would like to access"), | 306 | GNUNET_GETOPT_OPTION_STRING ('i', |
307 | 1, &GNUNET_GETOPT_set_string, &service_name}, | 307 | "ip", |
308 | {'t', "tcp", NULL, | 308 | "IP", |
309 | gettext_noop ("service is offered via TCP"), | 309 | gettext_noop ("destination IP for the tunnel"), |
310 | 0, &GNUNET_GETOPT_set_one, &tcp}, | 310 | &target_ip), |
311 | {'u', "udp", NULL, | 311 | |
312 | gettext_noop ("service is offered via UDP"), | 312 | GNUNET_GETOPT_OPTION_STRING ('p', |
313 | 0, &GNUNET_GETOPT_set_one, &udp}, | 313 | "peer", |
314 | "PEERID", | ||
315 | gettext_noop ("peer offering the service we would like to access"), | ||
316 | &peer_id), | ||
317 | |||
318 | GNUNET_GETOPT_OPTION_STRING ('s', | ||
319 | "service", | ||
320 | "NAME", | ||
321 | gettext_noop ("name of the service we would like to access"), | ||
322 | &service_name), | ||
323 | |||
324 | GNUNET_GETOPT_OPTION_SET_ONE ('t', | ||
325 | "tcp", | ||
326 | gettext_noop ("service is offered via TCP"), | ||
327 | &tcp), | ||
328 | |||
329 | GNUNET_GETOPT_OPTION_SET_ONE ('u', | ||
330 | "udp", | ||
331 | gettext_noop ("service is offered via UDP"), | ||
332 | &udp), | ||
314 | 333 | ||
315 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), | 334 | GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), |
335 | |||
316 | GNUNET_GETOPT_OPTION_END | 336 | GNUNET_GETOPT_OPTION_END |
317 | }; | 337 | }; |
318 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 338 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |