diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-12-23 19:39:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-12-23 19:39:53 +0000 |
commit | 8dfd7bda2f139e2dac27e804167eedc3d227453e (patch) | |
tree | e79f5aa4b4565a10525ec81914e1ca8e005d30d6 /src/fs/gnunet-publish.c | |
parent | 41915db92e387410c82a290b69b8d800589a3700 (diff) | |
download | gnunet-8dfd7bda2f139e2dac27e804167eedc3d227453e.tar.gz gnunet-8dfd7bda2f139e2dac27e804167eedc3d227453e.zip |
add keywords from metadata for files
Diffstat (limited to 'src/fs/gnunet-publish.c')
-rw-r--r-- | src/fs/gnunet-publish.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 36e75a4ea..060403598 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -210,6 +210,27 @@ meta_printer (void *cls, | |||
210 | 210 | ||
211 | 211 | ||
212 | /** | 212 | /** |
213 | * Iterator printing keywords | ||
214 | * | ||
215 | * @param cls closure | ||
216 | * @param keyword the keyword | ||
217 | * @param is_mandatory is the keyword mandatory (in a search) | ||
218 | * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort | ||
219 | */ | ||
220 | |||
221 | static int | ||
222 | keyword_printer (void *cls, | ||
223 | const char *keyword, | ||
224 | int is_mandatory) | ||
225 | { | ||
226 | fprintf (stdout, | ||
227 | "\t%s\n", | ||
228 | keyword); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | |||
233 | /** | ||
213 | * Function called on all entries before the publication. This is | 234 | * Function called on all entries before the publication. This is |
214 | * where we perform modifications to the default based on command-line | 235 | * where we perform modifications to the default based on command-line |
215 | * options. | 236 | * options. |
@@ -276,14 +297,22 @@ publish_inspector (void *cls, | |||
276 | EXTRACTOR_METATYPE_FILENAME); | 297 | EXTRACTOR_METATYPE_FILENAME); |
277 | fs = GNUNET_STRINGS_byte_size_fancy (length); | 298 | fs = GNUNET_STRINGS_byte_size_fancy (length); |
278 | fprintf (stdout, | 299 | fprintf (stdout, |
279 | _("Keywords for file `%s' (%s)\n"), | 300 | _("Meta data for file `%s' (%s)\n"), |
280 | fn, | 301 | fn, |
281 | fs); | 302 | fs); |
282 | GNUNET_free (fn); | ||
283 | GNUNET_free (fs); | ||
284 | GNUNET_CONTAINER_meta_data_iterate (m, | 303 | GNUNET_CONTAINER_meta_data_iterate (m, |
285 | &meta_printer, | 304 | &meta_printer, |
286 | NULL); | 305 | NULL); |
306 | fprintf (stdout, | ||
307 | _("Keywords for file `%s' (%s)\n"), | ||
308 | fn, | ||
309 | fs); | ||
310 | GNUNET_free (fn); | ||
311 | GNUNET_free (fs); | ||
312 | if (NULL != *uri) | ||
313 | GNUNET_FS_uri_ksk_get_keywords (*uri, | ||
314 | &keyword_printer, | ||
315 | NULL); | ||
287 | fprintf (stdout, "\n"); | 316 | fprintf (stdout, "\n"); |
288 | } | 317 | } |
289 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m)) | 318 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m)) |
@@ -381,6 +410,7 @@ run (void *cls, | |||
381 | struct GNUNET_FS_FileInformation *fi; | 410 | struct GNUNET_FS_FileInformation *fi; |
382 | struct GNUNET_FS_Namespace *namespace; | 411 | struct GNUNET_FS_Namespace *namespace; |
383 | struct EXTRACTOR_PluginList *plugins; | 412 | struct EXTRACTOR_PluginList *plugins; |
413 | struct GNUNET_FS_Uri *keywords; | ||
384 | struct stat sbuf; | 414 | struct stat sbuf; |
385 | char *ex; | 415 | char *ex; |
386 | char *emsg; | 416 | char *emsg; |
@@ -538,16 +568,18 @@ run (void *cls, | |||
538 | GNUNET_FS_meta_data_extract_from_file (meta, | 568 | GNUNET_FS_meta_data_extract_from_file (meta, |
539 | args[0], | 569 | args[0], |
540 | plugins); | 570 | plugins); |
571 | keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); | ||
541 | fi = GNUNET_FS_file_information_create_from_file (ctx, | 572 | fi = GNUNET_FS_file_information_create_from_file (ctx, |
542 | NULL, | 573 | NULL, |
543 | args[0], | 574 | args[0], |
544 | NULL, | 575 | keywords, |
545 | NULL, | 576 | NULL, |
546 | !do_insert, | 577 | !do_insert, |
547 | anonymity, | 578 | anonymity, |
548 | priority, | 579 | priority, |
549 | GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION)); | 580 | GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION)); |
550 | GNUNET_break (fi != NULL); | 581 | GNUNET_break (fi != NULL); |
582 | GNUNET_FS_uri_destroy (keywords); | ||
551 | } | 583 | } |
552 | EXTRACTOR_plugin_remove_all (plugins); | 584 | EXTRACTOR_plugin_remove_all (plugins); |
553 | if (fi == NULL) | 585 | if (fi == NULL) |