diff options
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/Makefile.am | 1 | ||||
-rw-r--r-- | src/fs/fs_directory.c | 5 | ||||
-rw-r--r-- | src/fs/fs_download.c | 4 | ||||
-rw-r--r-- | src/fs/fs_search.c | 7 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 28 | ||||
-rw-r--r-- | src/fs/gnunet-download.c | 111 | ||||
-rw-r--r-- | src/fs/gnunet-pseudonym.c | 105 | ||||
-rw-r--r-- | src/fs/gnunet-publish.c | 47 | ||||
-rw-r--r-- | src/fs/gnunet-search.c | 47 |
9 files changed, 277 insertions, 78 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index a83eef460..df781e1e6 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -82,6 +82,7 @@ gnunet_pseudonym_SOURCES = \ | |||
82 | gnunet_pseudonym_LDADD = \ | 82 | gnunet_pseudonym_LDADD = \ |
83 | $(top_builddir)/src/fs/libgnunetfs.la \ | 83 | $(top_builddir)/src/fs/libgnunetfs.la \ |
84 | $(top_builddir)/src/util/libgnunetutil.la \ | 84 | $(top_builddir)/src/util/libgnunetutil.la \ |
85 | -lextractor \ | ||
85 | $(GN_LIBINTL) | 86 | $(GN_LIBINTL) |
86 | 87 | ||
87 | gnunet_search_SOURCES = \ | 88 | gnunet_search_SOURCES = \ |
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index 48578c650..82d0e8690 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c | |||
@@ -291,7 +291,10 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData *mdir | |||
291 | struct GNUNET_FS_DirectoryBuilder *ret; | 291 | struct GNUNET_FS_DirectoryBuilder *ret; |
292 | 292 | ||
293 | ret = GNUNET_malloc(sizeof(struct GNUNET_FS_DirectoryBuilder)); | 293 | ret = GNUNET_malloc(sizeof(struct GNUNET_FS_DirectoryBuilder)); |
294 | ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir); | 294 | if (mdir != NULL) |
295 | ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir); | ||
296 | else | ||
297 | ret->meta = GNUNET_CONTAINER_meta_data_create (); | ||
295 | GNUNET_FS_meta_data_make_directory (ret->meta); | 298 | GNUNET_FS_meta_data_make_directory (ret->meta); |
296 | return ret; | 299 | return ret; |
297 | } | 300 | } |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 12d6ff0b6..3de192e12 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -23,10 +23,10 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | * | 24 | * |
25 | * TODO: | 25 | * TODO: |
26 | * - handle recursive downloads (need directory & | ||
27 | * fs-level download-parallelism management) | ||
26 | * - location URI suppport (can wait, easy) | 28 | * - location URI suppport (can wait, easy) |
27 | * - check if blocks exist already (can wait, easy) | 29 | * - check if blocks exist already (can wait, easy) |
28 | * - handle recursive downloads (need directory & | ||
29 | * fs-level download-parallelism management, can wait) | ||
30 | * - check if iblocks can be computed from existing blocks (can wait, hard) | 30 | * - check if iblocks can be computed from existing blocks (can wait, hard) |
31 | * - persistence (can wait) | 31 | * - persistence (can wait) |
32 | */ | 32 | */ |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 596ea0c63..c4994b6a6 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -24,12 +24,11 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * TODO: | 26 | * TODO: |
27 | * - handle SKS updates searches nicely (can wait) | 27 | * - handle namespace advertisements (can wait; might already work!?) |
28 | * - handle availability probes (can wait) | ||
29 | * - make operations persistent (can wait) | ||
30 | * - handle namespace advertisements (can wait) | ||
31 | * - add support for pushing "already seen" information | 28 | * - add support for pushing "already seen" information |
32 | * to FS service for bloomfilter (can wait) | 29 | * to FS service for bloomfilter (can wait) |
30 | * - handle availability probes (can wait) | ||
31 | * - make operations persistent (can wait) | ||
33 | */ | 32 | */ |
34 | 33 | ||
35 | #include "platform.h" | 34 | #include "platform.h" |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index b402fa830..5ddb48f2a 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -882,6 +882,34 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, | |||
882 | 882 | ||
883 | 883 | ||
884 | /** | 884 | /** |
885 | * Create an SKS URI from a namespace and an identifier. | ||
886 | * | ||
887 | * @param ns namespace | ||
888 | * @param id identifier | ||
889 | * @param emsg where to store an error message | ||
890 | * @return an FS URI for the given namespace and identifier | ||
891 | */ | ||
892 | struct GNUNET_FS_Uri * | ||
893 | GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, | ||
894 | const char *id, | ||
895 | char **emsg) | ||
896 | { | ||
897 | struct GNUNET_FS_Uri *ns_uri; | ||
898 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; | ||
899 | |||
900 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | ||
901 | ns_uri->type = sks; | ||
902 | GNUNET_CRYPTO_rsa_key_get_public (ns->key, | ||
903 | &pk); | ||
904 | GNUNET_CRYPTO_hash (&pk, | ||
905 | sizeof (pk), | ||
906 | &ns_uri->data.sks.namespace); | ||
907 | ns_uri->data.sks.identifier = GNUNET_strdup (id); | ||
908 | return ns_uri; | ||
909 | } | ||
910 | |||
911 | |||
912 | /** | ||
885 | * Canonicalize a keyword. | 913 | * Canonicalize a keyword. |
886 | * | 914 | * |
887 | * @param in input string (the keyword) | 915 | * @param in input string (the keyword) |
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index 5279ce459..63895d4b2 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * @author Igor Wronsky | 26 | * @author Igor Wronsky |
27 | * | 27 | * |
28 | * TODO: | 28 | * TODO: |
29 | * - many command-line options | 29 | * - download-directory option support (do_directory) |
30 | */ | 30 | */ |
31 | #include "platform.h" | 31 | #include "platform.h" |
32 | #include "gnunet_fs_service.h" | 32 | #include "gnunet_fs_service.h" |
@@ -47,6 +47,12 @@ static struct GNUNET_FS_DownloadContext *dc; | |||
47 | 47 | ||
48 | static unsigned int anonymity = 1; | 48 | static unsigned int anonymity = 1; |
49 | 49 | ||
50 | static unsigned int parallelism = 16; | ||
51 | |||
52 | static int do_recursive; | ||
53 | |||
54 | static int do_directory; | ||
55 | |||
50 | static char *filename; | 56 | static char *filename; |
51 | 57 | ||
52 | 58 | ||
@@ -127,8 +133,15 @@ progress_cb (void *cls, | |||
127 | info->value.download.filename, | 133 | info->value.download.filename, |
128 | s); | 134 | s); |
129 | GNUNET_free (s); | 135 | GNUNET_free (s); |
130 | if (info->value.download.dc == dc) | 136 | if (do_directory) |
131 | GNUNET_SCHEDULER_shutdown (sched); | 137 | { |
138 | GNUNET_break (0); //FIXME: not implemented | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | if (info->value.download.dc == dc) | ||
143 | GNUNET_SCHEDULER_shutdown (sched); | ||
144 | } | ||
132 | break; | 145 | break; |
133 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | 146 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: |
134 | if (info->value.download.dc == dc) | 147 | if (info->value.download.dc == dc) |
@@ -168,25 +181,31 @@ run (void *cls, | |||
168 | enum GNUNET_FS_DownloadOptions options; | 181 | enum GNUNET_FS_DownloadOptions options; |
169 | 182 | ||
170 | sched = s; | 183 | sched = s; |
171 | /* FIXME: check arguments */ | 184 | if (do_directory) |
172 | uri = GNUNET_FS_uri_parse (args[0], | ||
173 | &emsg); | ||
174 | if (NULL == uri) | ||
175 | { | 185 | { |
176 | fprintf (stderr, | 186 | GNUNET_break (0); //FIXME: not implemented |
177 | _("Failed to parse URI: %s\n"), | ||
178 | emsg); | ||
179 | GNUNET_free (emsg); | ||
180 | ret = 1; | ||
181 | return; | ||
182 | } | 187 | } |
183 | if (! GNUNET_FS_uri_test_chk (uri)) | 188 | else |
184 | { | 189 | { |
185 | fprintf (stderr, | 190 | uri = GNUNET_FS_uri_parse (args[0], |
186 | "Only CHK URIs supported right now.\n"); | 191 | &emsg); |
187 | ret = 1; | 192 | if (NULL == uri) |
188 | GNUNET_FS_uri_destroy (uri); | 193 | { |
189 | return; | 194 | fprintf (stderr, |
195 | _("Failed to parse URI: %s\n"), | ||
196 | emsg); | ||
197 | GNUNET_free (emsg); | ||
198 | ret = 1; | ||
199 | return; | ||
200 | } | ||
201 | if (! GNUNET_FS_uri_test_chk (uri)) | ||
202 | { | ||
203 | fprintf (stderr, | ||
204 | "Only CHK URIs supported right now.\n"); | ||
205 | ret = 1; | ||
206 | GNUNET_FS_uri_destroy (uri); | ||
207 | return; | ||
208 | } | ||
190 | } | 209 | } |
191 | if (NULL == filename) | 210 | if (NULL == filename) |
192 | { | 211 | { |
@@ -203,6 +222,8 @@ run (void *cls, | |||
203 | &progress_cb, | 222 | &progress_cb, |
204 | NULL, | 223 | NULL, |
205 | GNUNET_FS_FLAGS_NONE, | 224 | GNUNET_FS_FLAGS_NONE, |
225 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, | ||
226 | parallelism, | ||
206 | GNUNET_FS_OPTIONS_END); | 227 | GNUNET_FS_OPTIONS_END); |
207 | if (NULL == ctx) | 228 | if (NULL == ctx) |
208 | { | 229 | { |
@@ -214,22 +235,31 @@ run (void *cls, | |||
214 | return; | 235 | return; |
215 | } | 236 | } |
216 | options = GNUNET_FS_DOWNLOAD_OPTION_NONE; | 237 | options = GNUNET_FS_DOWNLOAD_OPTION_NONE; |
217 | dc = GNUNET_FS_download_start (ctx, | 238 | if (do_recursive) |
218 | uri, | 239 | options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; |
219 | NULL, | 240 | if (do_directory) |
220 | filename, | ||
221 | 0, | ||
222 | GNUNET_FS_uri_chk_get_file_size (uri), | ||
223 | anonymity, | ||
224 | options, | ||
225 | NULL, | ||
226 | NULL); | ||
227 | GNUNET_FS_uri_destroy (uri); | ||
228 | if (dc == NULL) | ||
229 | { | 241 | { |
230 | GNUNET_FS_stop (ctx); | 242 | GNUNET_break (0); //FIXME: not implemented |
231 | ctx = NULL; | 243 | } |
232 | return; | 244 | else |
245 | { | ||
246 | dc = GNUNET_FS_download_start (ctx, | ||
247 | uri, | ||
248 | NULL, | ||
249 | filename, | ||
250 | 0, | ||
251 | GNUNET_FS_uri_chk_get_file_size (uri), | ||
252 | anonymity, | ||
253 | options, | ||
254 | NULL, | ||
255 | NULL); | ||
256 | GNUNET_FS_uri_destroy (uri); | ||
257 | if (dc == NULL) | ||
258 | { | ||
259 | GNUNET_FS_stop (ctx); | ||
260 | ctx = NULL; | ||
261 | return; | ||
262 | } | ||
233 | } | 263 | } |
234 | GNUNET_SCHEDULER_add_delayed (sched, | 264 | GNUNET_SCHEDULER_add_delayed (sched, |
235 | GNUNET_TIME_UNIT_FOREVER_REL, | 265 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -245,28 +275,23 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
245 | {'a', "anonymity", "LEVEL", | 275 | {'a', "anonymity", "LEVEL", |
246 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 276 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
247 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 277 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, |
248 | #if 0 | ||
249 | // FIXME: options! | ||
250 | {'d', "directory", NULL, | 278 | {'d', "directory", NULL, |
251 | gettext_noop | 279 | gettext_noop |
252 | ("download a GNUnet directory that has already been downloaded. Requires that a filename of an existing file is specified instead of the URI. The download will only download the top-level files in the directory unless the `-R' option is also specified."), | 280 | ("download a GNUnet directory that has already been downloaded. Requires that a filename of an existing file is specified instead of the URI. The download will only download the top-level files in the directory unless the `-R' option is also specified."), |
253 | 0, &GNUNET_getopt_configure_set_one, &do_directory}, | 281 | 0, &GNUNET_GETOPT_set_one, &do_directory}, |
254 | {'D', "delete-incomplete", NULL, | 282 | {'D', "delete-incomplete", NULL, |
255 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), | 283 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), |
256 | 0, &GNUNET_getopt_configure_set_one, &do_delete_incomplete}, | 284 | 0, &GNUNET_GETOPT_set_one, &delete_incomplete}, |
257 | #endif | ||
258 | {'o', "output", "FILENAME", | 285 | {'o', "output", "FILENAME", |
259 | gettext_noop ("write the file to FILENAME"), | 286 | gettext_noop ("write the file to FILENAME"), |
260 | 1, &GNUNET_GETOPT_set_string, &filename}, | 287 | 1, &GNUNET_GETOPT_set_string, &filename}, |
261 | #if 0 | ||
262 | {'p', "parallelism", "DOWNLOADS", | 288 | {'p', "parallelism", "DOWNLOADS", |
263 | gettext_noop | 289 | gettext_noop |
264 | ("set the maximum number of parallel downloads that are allowed"), | 290 | ("set the maximum number of parallel downloads that are allowed"), |
265 | 1, &GNUNET_getopt_configure_set_uint, ¶llelism}, | 291 | 1, &GNUNET_GETOPT_set_uint, ¶llelism}, |
266 | {'R', "recursive", NULL, | 292 | {'R', "recursive", NULL, |
267 | gettext_noop ("download a GNUnet directory recursively"), | 293 | gettext_noop ("download a GNUnet directory recursively"), |
268 | 0, &GNUNET_getopt_configure_set_one, &do_recursive}, | 294 | 0, &GNUNET_GETOPT_set_one, &do_recursive}, |
269 | #endif | ||
270 | {'V', "verbose", NULL, | 295 | {'V', "verbose", NULL, |
271 | gettext_noop ("be verbose (print progress information)"), | 296 | gettext_noop ("be verbose (print progress information)"), |
272 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 297 | 0, &GNUNET_GETOPT_set_one, &verbose}, |
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index 2d35e8e8c..b8bd12b35 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c | |||
@@ -66,11 +66,6 @@ static int print_local_only; | |||
66 | static struct GNUNET_CONTAINER_MetaData *adv_metadata; | 66 | static struct GNUNET_CONTAINER_MetaData *adv_metadata; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * -n option. | ||
70 | */ | ||
71 | static int no_advertising; | ||
72 | |||
73 | /** | ||
74 | * -p option. | 69 | * -p option. |
75 | */ | 70 | */ |
76 | static unsigned int priority = 365; | 71 | static unsigned int priority = 365; |
@@ -100,6 +95,10 @@ static struct GNUNET_FS_Handle *h; | |||
100 | */ | 95 | */ |
101 | static struct GNUNET_FS_Namespace *ns; | 96 | static struct GNUNET_FS_Namespace *ns; |
102 | 97 | ||
98 | /** | ||
99 | * Our configuration. | ||
100 | */ | ||
101 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
103 | 102 | ||
104 | static int ret; | 103 | static int ret; |
105 | 104 | ||
@@ -126,11 +125,45 @@ ns_printer (void *cls, | |||
126 | } | 125 | } |
127 | 126 | ||
128 | 127 | ||
128 | static int | ||
129 | pseudo_printer (void *cls, | ||
130 | const GNUNET_HashCode * | ||
131 | pseudonym, | ||
132 | const struct | ||
133 | GNUNET_CONTAINER_MetaData * md, | ||
134 | int rating) | ||
135 | { | ||
136 | char *id; | ||
137 | |||
138 | id = GNUNET_PSEUDONYM_id_to_name (cfg, | ||
139 | pseudonym); | ||
140 | if (id == NULL) | ||
141 | { | ||
142 | GNUNET_break (0); | ||
143 | return GNUNET_OK; | ||
144 | } | ||
145 | fprintf (stdout, | ||
146 | "%s (%d):\n", | ||
147 | id, | ||
148 | rating); | ||
149 | GNUNET_CONTAINER_meta_data_iterate (md, | ||
150 | &EXTRACTOR_meta_data_print, | ||
151 | stdout); | ||
152 | fprintf (stdout, "\n"); | ||
153 | GNUNET_free (id); | ||
154 | return GNUNET_OK; | ||
155 | } | ||
156 | |||
157 | |||
129 | static void | 158 | static void |
130 | post_advertising (void *cls, | 159 | post_advertising (void *cls, |
131 | const struct GNUNET_FS_Uri *uri, | 160 | const struct GNUNET_FS_Uri *uri, |
132 | const char *emsg) | 161 | const char *emsg) |
133 | { | 162 | { |
163 | GNUNET_HashCode nsid; | ||
164 | char *set; | ||
165 | int delta; | ||
166 | |||
134 | if (emsg != NULL) | 167 | if (emsg != NULL) |
135 | { | 168 | { |
136 | fprintf (stderr, "%s", emsg); | 169 | fprintf (stderr, "%s", emsg); |
@@ -153,7 +186,39 @@ post_advertising (void *cls, | |||
153 | } | 186 | } |
154 | if (NULL != rating_change) | 187 | if (NULL != rating_change) |
155 | { | 188 | { |
156 | GNUNET_break (0); // FIXME: not implemented | 189 | set = rating_change; |
190 | while ((*set != '\0') && (*set != ':')) | ||
191 | set++; | ||
192 | if (*set != ':') | ||
193 | { | ||
194 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
195 | _("Invalid argument `%s'\n"), | ||
196 | rating_change); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | *set = '\0'; | ||
201 | delta = strtol (&set[1], NULL, /* no error handling yet */ | ||
202 | 10); | ||
203 | if (GNUNET_OK == | ||
204 | GNUNET_PSEUDONYM_name_to_id (cfg, | ||
205 | rating_change, | ||
206 | &nsid)) | ||
207 | { | ||
208 | GNUNET_PSEUDONYM_rank (cfg, | ||
209 | &nsid, | ||
210 | delta); | ||
211 | |||
212 | } | ||
213 | else | ||
214 | { | ||
215 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
216 | _("Namespace `%s' unknown.\n"), | ||
217 | rating_change); | ||
218 | } | ||
219 | } | ||
220 | GNUNET_free (rating_change); | ||
221 | rating_change = NULL; | ||
157 | } | 222 | } |
158 | if (0 != print_local_only) | 223 | if (0 != print_local_only) |
159 | { | 224 | { |
@@ -163,10 +228,10 @@ post_advertising (void *cls, | |||
163 | } | 228 | } |
164 | else if (0 == no_remote_printing) | 229 | else if (0 == no_remote_printing) |
165 | { | 230 | { |
166 | GNUNET_break (0); // FIXME: not implemented | 231 | GNUNET_PSEUDONYM_list_all (cfg, |
232 | &pseudo_printer, | ||
233 | NULL); | ||
167 | } | 234 | } |
168 | /* FIXME: is this OK here, or do we need | ||
169 | for completion of previous requests? */ | ||
170 | GNUNET_FS_stop (h); | 235 | GNUNET_FS_stop (h); |
171 | } | 236 | } |
172 | 237 | ||
@@ -178,18 +243,20 @@ post_advertising (void *cls, | |||
178 | * @param sched the scheduler to use | 243 | * @param sched the scheduler to use |
179 | * @param args remaining command-line arguments | 244 | * @param args remaining command-line arguments |
180 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 245 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
181 | * @param cfg configuration | 246 | * @param c configuration |
182 | */ | 247 | */ |
183 | static void | 248 | static void |
184 | run (void *cls, | 249 | run (void *cls, |
185 | struct GNUNET_SCHEDULER_Handle *sched, | 250 | struct GNUNET_SCHEDULER_Handle *sched, |
186 | char *const *args, | 251 | char *const *args, |
187 | const char *cfgfile, | 252 | const char *cfgfile, |
188 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 253 | const struct GNUNET_CONFIGURATION_Handle *c) |
189 | { | 254 | { |
190 | struct GNUNET_FS_Uri *ns_uri; | 255 | struct GNUNET_FS_Uri *ns_uri; |
191 | struct GNUNET_TIME_Absolute expiration; | 256 | struct GNUNET_TIME_Absolute expiration; |
257 | char *emsg; | ||
192 | 258 | ||
259 | cfg = c; | ||
193 | h = GNUNET_FS_start (sched, | 260 | h = GNUNET_FS_start (sched, |
194 | cfg, | 261 | cfg, |
195 | "gnunet-pseudonym", | 262 | "gnunet-pseudonym", |
@@ -221,11 +288,18 @@ run (void *cls, | |||
221 | } | 288 | } |
222 | else | 289 | else |
223 | { | 290 | { |
224 | if (0 == no_advertising) | 291 | if (NULL != root_identifier) |
225 | { | 292 | { |
226 | GNUNET_break (0); // FIXME: not implemented | 293 | emsg = NULL; |
227 | ns_uri = NULL; // FIXME!! | 294 | ns_uri = GNUNET_FS_uri_sks_create (ns, root_identifier, &emsg); |
295 | GNUNET_assert (emsg == NULL); | ||
228 | expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); | 296 | expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); |
297 | if (ksk_uri == NULL) | ||
298 | { | ||
299 | emsg = NULL; | ||
300 | ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); | ||
301 | GNUNET_assert (NULL == emsg); | ||
302 | } | ||
229 | GNUNET_FS_publish_ksk (h, | 303 | GNUNET_FS_publish_ksk (h, |
230 | ksk_uri, | 304 | ksk_uri, |
231 | adv_metadata, | 305 | adv_metadata, |
@@ -275,9 +349,6 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
275 | {'m', "meta", "TYPE:VALUE", | 349 | {'m', "meta", "TYPE:VALUE", |
276 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), | 350 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
277 | 1, &GNUNET_FS_getopt_set_metadata, &adv_metadata}, | 351 | 1, &GNUNET_FS_getopt_set_metadata, &adv_metadata}, |
278 | {'n', "no-advertisement", NULL, | ||
279 | gettext_noop ("do not create an advertisement"), | ||
280 | 0, &GNUNET_GETOPT_set_one, &no_advertising}, | ||
281 | {'p', "priority", "PRIORITY", | 352 | {'p', "priority", "PRIORITY", |
282 | gettext_noop ("use the given PRIORITY for the advertisments"), | 353 | gettext_noop ("use the given PRIORITY for the advertisments"), |
283 | 1, &GNUNET_GETOPT_set_uint, &priority}, | 354 | 1, &GNUNET_GETOPT_set_uint, &priority}, |
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 860a81522..1e0884361 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -24,9 +24,6 @@ | |||
24 | * @author Krista Bennett | 24 | * @author Krista Bennett |
25 | * @author James Blackwell | 25 | * @author James Blackwell |
26 | * @author Igor Wronsky | 26 | * @author Igor Wronsky |
27 | * | ||
28 | * TODO: | ||
29 | * - support for some options is still missing (uri argument) | ||
30 | */ | 27 | */ |
31 | #include "platform.h" | 28 | #include "platform.h" |
32 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
@@ -307,6 +304,22 @@ publish_inspector (void *cls, | |||
307 | } | 304 | } |
308 | 305 | ||
309 | 306 | ||
307 | static void | ||
308 | uri_ksk_continuation (void *cls, | ||
309 | const struct GNUNET_FS_Uri *uri, | ||
310 | const char *emsg) | ||
311 | { | ||
312 | if (emsg != NULL) | ||
313 | { | ||
314 | fprintf (stderr, | ||
315 | "%s\n", | ||
316 | emsg); | ||
317 | ret = 1; | ||
318 | } | ||
319 | GNUNET_FS_stop (ctx); | ||
320 | } | ||
321 | |||
322 | |||
310 | /** | 323 | /** |
311 | * Main function that will be run by the scheduler. | 324 | * Main function that will be run by the scheduler. |
312 | * | 325 | * |
@@ -329,6 +342,7 @@ run (void *cls, | |||
329 | struct stat sbuf; | 342 | struct stat sbuf; |
330 | char *ex; | 343 | char *ex; |
331 | char *emsg; | 344 | char *emsg; |
345 | struct GNUNET_FS_Uri *uri; | ||
332 | 346 | ||
333 | sched = s; | 347 | sched = s; |
334 | /* check arguments */ | 348 | /* check arguments */ |
@@ -421,11 +435,32 @@ run (void *cls, | |||
421 | } | 435 | } |
422 | } | 436 | } |
423 | if (NULL != uri_string) | 437 | if (NULL != uri_string) |
424 | { | 438 | { |
425 | // FIXME -- implement! | 439 | emsg = NULL; |
440 | uri = GNUNET_FS_uri_parse (uri_string, | ||
441 | &emsg); | ||
442 | if (uri == NULL) | ||
443 | { | ||
444 | fprintf (stderr, | ||
445 | _("Failed to parse URI: %s\n"), | ||
446 | emsg); | ||
447 | GNUNET_free (emsg); | ||
448 | GNUNET_FS_stop (ctx); | ||
449 | ret = 1; | ||
450 | return; | ||
451 | } | ||
452 | GNUNET_FS_publish_ksk (ctx, | ||
453 | topKeywords, | ||
454 | meta, | ||
455 | uri, | ||
456 | GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION), | ||
457 | anonymity, | ||
458 | priority, | ||
459 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
460 | &uri_ksk_continuation, | ||
461 | NULL); | ||
426 | return; | 462 | return; |
427 | } | 463 | } |
428 | |||
429 | l = NULL; | 464 | l = NULL; |
430 | if (! disable_extractor) | 465 | if (! disable_extractor) |
431 | { | 466 | { |
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index 462f432c8..33c81c9d7 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -24,9 +24,6 @@ | |||
24 | * @author Krista Bennett | 24 | * @author Krista Bennett |
25 | * @author James Blackwell | 25 | * @author James Blackwell |
26 | * @author Igor Wronsky | 26 | * @author Igor Wronsky |
27 | * | ||
28 | * TODO: | ||
29 | * - add many options (timeout, namespace search, etc.) | ||
30 | */ | 27 | */ |
31 | #include "platform.h" | 28 | #include "platform.h" |
32 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
@@ -41,6 +38,10 @@ static struct GNUNET_FS_Handle *ctx; | |||
41 | 38 | ||
42 | static struct GNUNET_FS_SearchContext *sc; | 39 | static struct GNUNET_FS_SearchContext *sc; |
43 | 40 | ||
41 | static char *output_filename; | ||
42 | |||
43 | static struct GNUNET_FS_DirectoryBuilder *db; | ||
44 | |||
44 | static unsigned int anonymity = 1; | 45 | static unsigned int anonymity = 1; |
45 | 46 | ||
46 | static int verbose; | 47 | static int verbose; |
@@ -64,12 +65,39 @@ item_printer (void *cls, | |||
64 | return GNUNET_OK; | 65 | return GNUNET_OK; |
65 | } | 66 | } |
66 | 67 | ||
68 | |||
67 | static void | 69 | static void |
68 | clean_task (void *cls, | 70 | clean_task (void *cls, |
69 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 71 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
70 | { | 72 | { |
73 | size_t dsize; | ||
74 | void *ddata; | ||
75 | |||
71 | GNUNET_FS_stop (ctx); | 76 | GNUNET_FS_stop (ctx); |
72 | ctx = NULL; | 77 | ctx = NULL; |
78 | if (output_filename == NULL) | ||
79 | return; | ||
80 | if (GNUNET_OK != | ||
81 | GNUNET_FS_directory_builder_finish (db, | ||
82 | &dsize, | ||
83 | &ddata)) | ||
84 | { | ||
85 | GNUNET_break (0); | ||
86 | GNUNET_free (output_filename); | ||
87 | return; | ||
88 | } | ||
89 | if (dsize != | ||
90 | GNUNET_DISK_fn_write (output_filename, | ||
91 | ddata, | ||
92 | dsize, | ||
93 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) | ||
94 | { | ||
95 | fprintf (stderr, | ||
96 | _("Failed to write directory with search results to `%s'\n"), | ||
97 | output_filename); | ||
98 | } | ||
99 | GNUNET_free_non_null (ddata); | ||
100 | GNUNET_free (output_filename); | ||
73 | } | 101 | } |
74 | 102 | ||
75 | 103 | ||
@@ -99,6 +127,11 @@ progress_cb (void *cls, | |||
99 | case GNUNET_FS_STATUS_SEARCH_START: | 127 | case GNUNET_FS_STATUS_SEARCH_START: |
100 | break; | 128 | break; |
101 | case GNUNET_FS_STATUS_SEARCH_RESULT: | 129 | case GNUNET_FS_STATUS_SEARCH_RESULT: |
130 | if (db != NULL) | ||
131 | GNUNET_FS_directory_builder_add (db, | ||
132 | info->value.search.specifics.result.uri, | ||
133 | info->value.search.specifics.result.meta, | ||
134 | NULL); | ||
102 | uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri); | 135 | uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri); |
103 | printf ("%s:\n", uri); | 136 | printf ("%s:\n", uri); |
104 | filename = | 137 | filename = |
@@ -135,7 +168,6 @@ progress_cb (void *cls, | |||
135 | GNUNET_SCHEDULER_shutdown (sched); | 168 | GNUNET_SCHEDULER_shutdown (sched); |
136 | break; | 169 | break; |
137 | case GNUNET_FS_STATUS_SEARCH_STOPPED: | 170 | case GNUNET_FS_STATUS_SEARCH_STOPPED: |
138 | sc = NULL; | ||
139 | GNUNET_SCHEDULER_add_continuation (sched, | 171 | GNUNET_SCHEDULER_add_continuation (sched, |
140 | &clean_task, | 172 | &clean_task, |
141 | NULL, | 173 | NULL, |
@@ -214,6 +246,8 @@ run (void *cls, | |||
214 | ret = 1; | 246 | ret = 1; |
215 | return; | 247 | return; |
216 | } | 248 | } |
249 | if (output_filename != NULL) | ||
250 | db = GNUNET_FS_directory_builder_create (NULL); | ||
217 | sc = GNUNET_FS_search_start (ctx, | 251 | sc = GNUNET_FS_search_start (ctx, |
218 | uri, | 252 | uri, |
219 | anonymity, | 253 | anonymity, |
@@ -241,7 +275,10 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = { | |||
241 | {'a', "anonymity", "LEVEL", | 275 | {'a', "anonymity", "LEVEL", |
242 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 276 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
243 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 277 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, |
244 | // FIXME: options! | 278 | {'o', "output", "PREFIX", |
279 | gettext_noop | ||
280 | ("write search results to file starting with PREFIX"), | ||
281 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | ||
245 | GNUNET_GETOPT_OPTION_END | 282 | GNUNET_GETOPT_OPTION_END |
246 | }; | 283 | }; |
247 | 284 | ||