diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-16 15:26:57 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-03-16 15:26:57 +0100 |
commit | 1c4f90e7c538f1489ea17be3d2f655c2390d7ccf (patch) | |
tree | 9a8dc8245d1ffe456076cc8612754d0d9dd7298f /src/fs | |
parent | 04a46ba5acf180be6f3a7d85cd6f6ce0ff13b1ba (diff) | |
download | gnunet-1c4f90e7c538f1489ea17be3d2f655c2390d7ccf.tar.gz gnunet-1c4f90e7c538f1489ea17be3d2f655c2390d7ccf.zip |
porting gnunet-publish + others..
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_getopt.c | 79 | ||||
-rw-r--r-- | src/fs/gnunet-auto-share.c | 54 | ||||
-rw-r--r-- | src/fs/gnunet-download.c | 74 | ||||
-rw-r--r-- | src/fs/gnunet-publish.c | 151 |
4 files changed, 242 insertions, 116 deletions
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-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 = |