gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14063 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r14063 - gnunet/src/fs
Date: Thu, 23 Dec 2010 20:39:53 +0100

Author: grothoff
Date: 2010-12-23 20:39:53 +0100 (Thu, 23 Dec 2010)
New Revision: 14063

Modified:
   gnunet/src/fs/gnunet-publish.c
Log:
add keywords from metadata for files

Modified: gnunet/src/fs/gnunet-publish.c
===================================================================
--- gnunet/src/fs/gnunet-publish.c      2010-12-23 16:51:46 UTC (rev 14062)
+++ gnunet/src/fs/gnunet-publish.c      2010-12-23 19:39:53 UTC (rev 14063)
@@ -210,6 +210,27 @@
 
 
 /**
+ * Iterator printing keywords
+ *
+ * @param cls closure
+ * @param keyword the keyword
+ * @param is_mandatory is the keyword mandatory (in a search)
+ * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
+ */
+
+static int
+keyword_printer (void *cls,
+                const char *keyword,
+                int is_mandatory)
+{
+  fprintf (stdout, 
+          "\t%s\n",
+          keyword);
+  return 0;
+}
+
+
+/**
  * Function called on all entries before the publication.  This is
  * where we perform modifications to the default based on command-line
  * options.
@@ -276,14 +297,22 @@
                                                   EXTRACTOR_METATYPE_FILENAME);
       fs = GNUNET_STRINGS_byte_size_fancy (length);
       fprintf (stdout,
+              _("Meta data for file `%s' (%s)\n"),
+              fn,
+              fs);
+      GNUNET_CONTAINER_meta_data_iterate (m,
+                                         &meta_printer,
+                                         NULL);
+      fprintf (stdout,
               _("Keywords for file `%s' (%s)\n"),
               fn,
               fs);
       GNUNET_free (fn);
       GNUNET_free (fs);
-      GNUNET_CONTAINER_meta_data_iterate (m,
-                                         &meta_printer,
-                                         NULL);
+      if (NULL != *uri)
+       GNUNET_FS_uri_ksk_get_keywords (*uri,
+                                       &keyword_printer,
+                                       NULL);
       fprintf (stdout, "\n");
     }
   if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
@@ -381,6 +410,7 @@
   struct GNUNET_FS_FileInformation *fi;
   struct GNUNET_FS_Namespace *namespace;
   struct EXTRACTOR_PluginList *plugins;
+  struct GNUNET_FS_Uri *keywords;
   struct stat sbuf;
   char *ex;
   char *emsg;
@@ -538,16 +568,18 @@
       GNUNET_FS_meta_data_extract_from_file (meta,
                                             args[0],
                                             plugins);
+      keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
       fi = GNUNET_FS_file_information_create_from_file (ctx,
                                                        NULL,
                                                        args[0],
+                                                       keywords,
                                                        NULL,
-                                                       NULL,
                                                        !do_insert,
                                                        anonymity,
                                                        priority,
                                                        
GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
       GNUNET_break (fi != NULL);
+      GNUNET_FS_uri_destroy (keywords);
     }
   EXTRACTOR_plugin_remove_all (plugins);  
   if (fi == NULL)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]