diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-15 16:21:06 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-15 16:21:06 +0100 |
commit | e6b3fec9e4a573e1f0c594a3c2f345357c0c12b8 (patch) | |
tree | 2fecdbebccc0970ff483ed28ea327f056f87423b /src/dht | |
parent | 5d6ed5fbda01a324d8d9b800928339d4a90343c3 (diff) | |
download | gnunet-e6b3fec9e4a573e1f0c594a3c2f345357c0c12b8.tar.gz gnunet-e6b3fec9e4a573e1f0c594a3c2f345357c0c12b8.zip |
getopt API porting.
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-dht-get.c | 71 | ||||
-rw-r--r-- | src/dht/gnunet-dht-monitor.c | 50 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 87 | ||||
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 73 |
4 files changed, 173 insertions, 108 deletions
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index ce479dc3e..812e62b17 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,48 @@ 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_SET_ONE ('V', | ||
273 | "verbose", | ||
274 | gettext_noop ("be verbose (print progress information)"), | ||
275 | &verbose), | ||
276 | GNUNET_GETOPT_OPTION_END | ||
277 | }; | ||
278 | |||
279 | |||
280 | |||
266 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 281 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
267 | return 2; | 282 | return 2; |
268 | return (GNUNET_OK == | 283 | 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..55644a94c 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,58 @@ 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_SET_ONE ('V', | ||
248 | "verbose", | ||
249 | gettext_noop ("be verbose (print progress information)"), | ||
250 | &verbose), | ||
251 | |||
252 | GNUNET_GETOPT_OPTION_END | ||
253 | }; | ||
254 | |||
255 | |||
237 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, | 256 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, |
238 | &argc, &argv)) | 257 | &argc, &argv)) |
239 | return 2; | 258 | 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 | ||