diff options
author | Nils Gillmann <ng0@n0.is> | 2018-11-13 11:42:15 +0000 |
---|---|---|
committer | Nils Gillmann <ng0@n0.is> | 2018-11-13 11:42:15 +0000 |
commit | 9d1e77b9331acb9bd8b6c99aa942f62b9759e650 (patch) | |
tree | 85475b117fff75b563a6f9512d3ead476a830f7d /src/fs | |
parent | e8a1a082555f98af40f98fd3a20ccd803ad478f8 (diff) | |
parent | 98288a7b26344294a3668101b9c2b502dfc19e12 (diff) | |
download | gnunet-9d1e77b9331acb9bd8b6c99aa942f62b9759e650.tar.gz gnunet-9d1e77b9331acb9bd8b6c99aa942f62b9759e650.zip |
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_getopt.c | 29 | ||||
-rw-r--r-- | src/fs/gnunet-publish.c | 60 | ||||
-rw-r--r-- | src/fs/gnunet-search.c | 49 |
3 files changed, 72 insertions, 66 deletions
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index 7b5c2991d..cbd9339c9 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c | |||
@@ -38,19 +38,20 @@ | |||
38 | * @param scls must be of type "struct GNUNET_FS_Uri **" | 38 | * @param scls must be of type "struct GNUNET_FS_Uri **" |
39 | * @param option name of the option (typically 'k') | 39 | * @param option name of the option (typically 'k') |
40 | * @param value command line argument given | 40 | * @param value command line argument given |
41 | * @return GNUNET_OK on success | 41 | * @return #GNUNET_OK on success |
42 | */ | 42 | */ |
43 | static int | 43 | static int |
44 | getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | 44 | getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
45 | *ctx, void *scls, const char *option, | 45 | void *scls, |
46 | const char *value) | 46 | const char *option, |
47 | const char *value) | ||
47 | { | 48 | { |
48 | struct GNUNET_FS_Uri **uri = scls; | 49 | struct GNUNET_FS_Uri **uri = scls; |
49 | struct GNUNET_FS_Uri *u = *uri; | 50 | struct GNUNET_FS_Uri *u = *uri; |
50 | char *val; | 51 | char *val; |
51 | size_t slen; | 52 | size_t slen; |
52 | 53 | ||
53 | if (u == NULL) | 54 | if (NULL == u) |
54 | { | 55 | { |
55 | u = GNUNET_new (struct GNUNET_FS_Uri); | 56 | u = GNUNET_new (struct GNUNET_FS_Uri); |
56 | *uri = u; | 57 | *uri = u; |
@@ -60,10 +61,10 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
60 | } | 61 | } |
61 | else | 62 | else |
62 | { | 63 | { |
63 | GNUNET_assert (u->type == GNUNET_FS_URI_KSK); | 64 | GNUNET_assert (GNUNET_FS_URI_KSK == u->type); |
64 | } | 65 | } |
65 | slen = strlen (value); | 66 | slen = strlen (value); |
66 | if (slen == 0) | 67 | if (0 == slen) |
67 | return GNUNET_SYSERR; /* cannot be empty */ | 68 | return GNUNET_SYSERR; /* cannot be empty */ |
68 | if (value[0] == '+') | 69 | if (value[0] == '+') |
69 | { | 70 | { |
@@ -75,7 +76,9 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
75 | /* remove the quotes, keep the '+' */ | 76 | /* remove the quotes, keep the '+' */ |
76 | val = GNUNET_malloc (slen - 1); | 77 | val = GNUNET_malloc (slen - 1); |
77 | val[0] = '+'; | 78 | val[0] = '+'; |
78 | GNUNET_memcpy (&val[1], &value[2], slen - 3); | 79 | GNUNET_memcpy (&val[1], |
80 | &value[2], | ||
81 | slen - 3); | ||
79 | val[slen - 2] = '\0'; | 82 | val[slen - 2] = '\0'; |
80 | } | 83 | } |
81 | else | 84 | else |
@@ -91,7 +94,9 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
91 | /* remove the quotes, add a space */ | 94 | /* remove the quotes, add a space */ |
92 | val = GNUNET_malloc (slen); | 95 | val = GNUNET_malloc (slen); |
93 | val[0] = ' '; | 96 | val[0] = ' '; |
94 | GNUNET_memcpy (&val[1], &value[1], slen - 2); | 97 | GNUNET_memcpy (&val[1], |
98 | &value[1], | ||
99 | slen - 2); | ||
95 | val[slen - 1] = '\0'; | 100 | val[slen - 1] = '\0'; |
96 | } | 101 | } |
97 | else | 102 | else |
@@ -102,10 +107,13 @@ getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
102 | strcat (val, value); | 107 | strcat (val, value); |
103 | } | 108 | } |
104 | } | 109 | } |
105 | GNUNET_array_append (u->data.ksk.keywords, u->data.ksk.keywordCount, val); | 110 | GNUNET_array_append (u->data.ksk.keywords, |
111 | u->data.ksk.keywordCount, | ||
112 | val); | ||
106 | return GNUNET_OK; | 113 | return GNUNET_OK; |
107 | } | 114 | } |
108 | 115 | ||
116 | |||
109 | /** | 117 | /** |
110 | * Allow user to specify keywords. | 118 | * Allow user to specify keywords. |
111 | * | 119 | * |
@@ -135,6 +143,7 @@ GNUNET_FS_GETOPT_KEYWORDS (char shortName, | |||
135 | return clo; | 143 | return clo; |
136 | } | 144 | } |
137 | 145 | ||
146 | |||
138 | /** | 147 | /** |
139 | * Command-line option parser function that allows the user to specify | 148 | * Command-line option parser function that allows the user to specify |
140 | * one or more '-m' options with metadata. Each specified entry of | 149 | * one or more '-m' options with metadata. Each specified entry of |
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 999301c2f..ffcf9b5d0 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -496,21 +496,22 @@ uri_ksk_continuation (void *cls, | |||
496 | emsg); | 496 | emsg); |
497 | ret = 1; | 497 | ret = 1; |
498 | } | 498 | } |
499 | if (NULL != namespace) | 499 | if (NULL == namespace) |
500 | { | 500 | { |
501 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); | 501 | GNUNET_SCHEDULER_shutdown (); |
502 | GNUNET_FS_publish_sks (ctx, | ||
503 | priv, | ||
504 | this_id, | ||
505 | next_id, | ||
506 | meta, | ||
507 | uri, | ||
508 | &bo, | ||
509 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
510 | &uri_sks_continuation, NULL); | ||
511 | return; | 502 | return; |
512 | } | 503 | } |
513 | GNUNET_SCHEDULER_shutdown (); | 504 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); |
505 | GNUNET_FS_publish_sks (ctx, | ||
506 | priv, | ||
507 | this_id, | ||
508 | next_id, | ||
509 | meta, | ||
510 | uri, | ||
511 | &bo, | ||
512 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
513 | &uri_sks_continuation, | ||
514 | NULL); | ||
514 | } | 515 | } |
515 | 516 | ||
516 | 517 | ||
@@ -728,7 +729,8 @@ identity_continuation (const char *args0) | |||
728 | GNUNET_SCHEDULER_shutdown (); | 729 | GNUNET_SCHEDULER_shutdown (); |
729 | return; | 730 | return; |
730 | } | 731 | } |
731 | GNUNET_FS_publish_ksk (ctx, topKeywords, | 732 | GNUNET_FS_publish_ksk (ctx, |
733 | topKeywords, | ||
732 | meta, uri, | 734 | meta, uri, |
733 | &bo, | 735 | &bo, |
734 | GNUNET_FS_PUBLISH_OPTION_NONE, | 736 | GNUNET_FS_PUBLISH_OPTION_NONE, |
@@ -889,7 +891,8 @@ run (void *cls, | |||
889 | * @return 0 ok, 1 on error | 891 | * @return 0 ok, 1 on error |
890 | */ | 892 | */ |
891 | int | 893 | int |
892 | main (int argc, char *const *argv) | 894 | main (int argc, |
895 | char *const *argv) | ||
893 | { | 896 | { |
894 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 897 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
895 | GNUNET_GETOPT_option_uint ('a', | 898 | GNUNET_GETOPT_option_uint ('a', |
@@ -922,26 +925,22 @@ main (int argc, char *const *argv) | |||
922 | "TYPE:VALUE", | 925 | "TYPE:VALUE", |
923 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), | 926 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
924 | &meta), | 927 | &meta), |
925 | |||
926 | GNUNET_GETOPT_option_flag ('n', | 928 | GNUNET_GETOPT_option_flag ('n', |
927 | "noindex", | 929 | "noindex", |
928 | gettext_noop ("do not index, perform full insertion (stores " | 930 | gettext_noop ("do not index, perform full insertion (stores " |
929 | "entire file in encrypted form in GNUnet database)"), | 931 | "entire file in encrypted form in GNUnet database)"), |
930 | &do_insert), | 932 | &do_insert), |
931 | |||
932 | GNUNET_GETOPT_option_string ('N', | 933 | GNUNET_GETOPT_option_string ('N', |
933 | "next", | 934 | "next", |
934 | "ID", | 935 | "ID", |
935 | gettext_noop ("specify ID of an updated version to be " | 936 | gettext_noop ("specify ID of an updated version to be " |
936 | "published in the future (for namespace insertions only)"), | 937 | "published in the future (for namespace insertions only)"), |
937 | &next_id), | 938 | &next_id), |
938 | |||
939 | GNUNET_GETOPT_option_uint ('p', | 939 | GNUNET_GETOPT_option_uint ('p', |
940 | "priority", | 940 | "priority", |
941 | "PRIORITY", | 941 | "PRIORITY", |
942 | gettext_noop ("specify the priority of the content"), | 942 | gettext_noop ("specify the priority of the content"), |
943 | &bo.content_priority), | 943 | &bo.content_priority), |
944 | |||
945 | GNUNET_GETOPT_option_string ('P', | 944 | GNUNET_GETOPT_option_string ('P', |
946 | "pseudonym", | 945 | "pseudonym", |
947 | "NAME", | 946 | "NAME", |
@@ -964,7 +963,6 @@ main (int argc, char *const *argv) | |||
964 | gettext_noop ("set the ID of this version of the publication " | 963 | gettext_noop ("set the ID of this version of the publication " |
965 | "(for namespace insertions only)"), | 964 | "(for namespace insertions only)"), |
966 | &this_id), | 965 | &this_id), |
967 | |||
968 | GNUNET_GETOPT_option_string ('u', | 966 | GNUNET_GETOPT_option_string ('u', |
969 | "uri", | 967 | "uri", |
970 | "URI", | 968 | "URI", |
@@ -982,10 +980,14 @@ main (int argc, char *const *argv) | |||
982 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 980 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
983 | return 2; | 981 | return 2; |
984 | ret = (GNUNET_OK == | 982 | ret = (GNUNET_OK == |
985 | GNUNET_PROGRAM_run (argc, argv, "gnunet-publish [OPTIONS] FILENAME", | 983 | GNUNET_PROGRAM_run (argc, |
984 | argv, | ||
985 | "gnunet-publish [OPTIONS] FILENAME", | ||
986 | gettext_noop | 986 | gettext_noop |
987 | ("Publish a file or directory on GNUnet"), | 987 | ("Publish a file or directory on GNUnet"), |
988 | options, &run, NULL)) ? ret : 1; | 988 | options, |
989 | &run, | ||
990 | NULL)) ? ret : 1; | ||
989 | GNUNET_free ((void*) argv); | 991 | GNUNET_free ((void*) argv); |
990 | return ret; | 992 | return ret; |
991 | } | 993 | } |
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index 780b3c93d..2a0a153e7 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -304,49 +304,44 @@ int | |||
304 | main (int argc, char *const *argv) | 304 | main (int argc, char *const *argv) |
305 | { | 305 | { |
306 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 306 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
307 | |||
308 | GNUNET_GETOPT_option_uint ('a', | 307 | GNUNET_GETOPT_option_uint ('a', |
309 | "anonymity", | 308 | "anonymity", |
310 | "LEVEL", | 309 | "LEVEL", |
311 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 310 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
312 | &anonymity), | 311 | &anonymity), |
313 | |||
314 | |||
315 | GNUNET_GETOPT_option_flag ('n', | 312 | GNUNET_GETOPT_option_flag ('n', |
316 | "no-network", | 313 | "no-network", |
317 | gettext_noop ("only search the local peer (no P2P network search)"), | 314 | gettext_noop ("only search the local peer (no P2P network search)"), |
318 | &local_only), | 315 | &local_only), |
319 | |||
320 | GNUNET_GETOPT_option_string ('o', | 316 | GNUNET_GETOPT_option_string ('o', |
321 | "output", | 317 | "output", |
322 | "PREFIX", | 318 | "PREFIX", |
323 | gettext_noop ("write search results to file starting with PREFIX"), | 319 | gettext_noop ("write search results to file starting with PREFIX"), |
324 | &output_filename), | 320 | &output_filename), |
325 | |||
326 | GNUNET_GETOPT_option_relative_time ('t', | 321 | GNUNET_GETOPT_option_relative_time ('t', |
327 | "timeout", | 322 | "timeout", |
328 | "DELAY", | 323 | "DELAY", |
329 | gettext_noop ("automatically terminate search after DELAY"), | 324 | gettext_noop ("automatically terminate search after DELAY"), |
330 | &timeout), | 325 | &timeout), |
331 | |||
332 | |||
333 | GNUNET_GETOPT_option_verbose (&verbose), | 326 | GNUNET_GETOPT_option_verbose (&verbose), |
334 | |||
335 | GNUNET_GETOPT_option_uint ('N', | 327 | GNUNET_GETOPT_option_uint ('N', |
336 | "results", | 328 | "results", |
337 | "VALUE", | 329 | "VALUE", |
338 | gettext_noop ("automatically terminate search " | 330 | gettext_noop ("automatically terminate search " |
339 | "after VALUE results are found"), | 331 | "after VALUE results are found"), |
340 | &results_limit), | 332 | &results_limit), |
341 | |||
342 | GNUNET_GETOPT_OPTION_END | 333 | GNUNET_GETOPT_OPTION_END |
343 | }; | 334 | }; |
344 | 335 | ||
345 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 336 | if (GNUNET_OK != |
337 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
338 | &argc, &argv)) | ||
346 | return 2; | 339 | return 2; |
347 | 340 | ||
348 | ret = (GNUNET_OK == | 341 | ret = (GNUNET_OK == |
349 | GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD", | 342 | GNUNET_PROGRAM_run (argc, |
343 | argv, | ||
344 | "gnunet-search [OPTIONS] KEYWORD", | ||
350 | gettext_noop | 345 | gettext_noop |
351 | ("Search GNUnet for files that were published on GNUnet"), | 346 | ("Search GNUnet for files that were published on GNUnet"), |
352 | options, &run, NULL)) ? ret : 1; | 347 | options, &run, NULL)) ? ret : 1; |