[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11086 - in gnunet/src: fs include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11086 - in gnunet/src: fs include util |
Date: |
Wed, 28 Apr 2010 10:07:19 +0200 |
Author: grothoff
Date: 2010-04-28 10:07:19 +0200 (Wed, 28 Apr 2010)
New Revision: 11086
Modified:
gnunet/src/fs/fs_search.c
gnunet/src/fs/gnunet-publish.c
gnunet/src/include/gnunet_container_lib.h
gnunet/src/util/container_meta_data.c
gnunet/src/util/pseudonym.c
Log:
merge meta data for search results
Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c 2010-04-28 07:58:12 UTC (rev 11085)
+++ gnunet/src/fs/fs_search.c 2010-04-28 08:07:19 UTC (rev 11086)
@@ -234,7 +234,7 @@
}
else
{
- /* FIXME: consider combining the meta data */
+ GNUNET_CONTAINER_meta_data_merge (sr->meta, meta);
}
/* check if mandatory satisfied */
if (ent->mandatory)
Modified: gnunet/src/fs/gnunet-publish.c
===================================================================
--- gnunet/src/fs/gnunet-publish.c 2010-04-28 07:58:12 UTC (rev 11085)
+++ gnunet/src/fs/gnunet-publish.c 2010-04-28 08:07:19 UTC (rev 11086)
@@ -216,40 +216,6 @@
/**
- * Merge metadata entries.
- *
- * @param cls closure, target metadata structure
- * @param plugin_name name of the plugin that generated the meta data
- * @param type type of the meta data
- * @param format format of data
- * @param data_mime_type mime type of data
- * @param data value of the meta data
- * @param data_size number of bytes in data
- * @return always 0
- */
-static int
-meta_merger (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_size)
-{
- struct GNUNET_CONTAINER_MetaData *m = cls;
-
- GNUNET_CONTAINER_meta_data_insert (m,
- plugin_name,
- type,
- format,
- data_mime_type,
- data,
- data_size);
- return 0;
-}
-
-
-/**
* Function called on all entries before the publication. This is
* where we perform modifications to the default based on command-line
* options.
@@ -302,9 +268,7 @@
}
if (NULL != meta)
{
- GNUNET_CONTAINER_meta_data_iterate (meta,
- &meta_merger,
- m);
+ GNUNET_CONTAINER_meta_data_merge (m, meta);
GNUNET_CONTAINER_meta_data_destroy (meta);
meta = NULL;
}
Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h 2010-04-28 07:58:12 UTC (rev
11085)
+++ gnunet/src/include/gnunet_container_lib.h 2010-04-28 08:07:19 UTC (rev
11086)
@@ -266,6 +266,18 @@
/**
+ * Extend metadata. Merges the meta data from the second argument
+ * into the first, discarding duplicate key-value pairs.
+ *
+ * @param md metadata to extend
+ * @param in metadata to merge
+ */
+void
+GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
+ const struct GNUNET_CONTAINER_MetaData *in);
+
+
+/**
* Remove an item.
*
* @param md metadata to manipulate
Modified: gnunet/src/util/container_meta_data.c
===================================================================
--- gnunet/src/util/container_meta_data.c 2010-04-28 07:58:12 UTC (rev
11085)
+++ gnunet/src/util/container_meta_data.c 2010-04-28 08:07:19 UTC (rev
11086)
@@ -311,6 +311,54 @@
/**
+ * Merge given meta data.
+ *
+ * @param cls the 'struct GNUNET_CONTAINER_MetaData' to merge into
+ * @param plugin_name name of the plugin that produced this value;
+ * special values can be used (i.e. '<zlib>' for zlib being
+ * used in the main libextractor library and yielding
+ * meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about data
+ * @param data_mime_type mime-type of data (not of the original file);
+ * can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_len number of bytes in data
+ * @return 0 (to continue)
+ */
+static int
+merge_helper(void *cls,
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
+{
+ struct GNUNET_CONTAINER_MetaData *md = cls;
+ (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name,
+ type, format,
+ data_mime_type, data, data_len);
+ return 0;
+}
+
+
+/**
+ * Extend metadata. Merges the meta data from the second argument
+ * into the first, discarding duplicate key-value pairs.
+ *
+ * @param md metadata to extend
+ * @param in metadata to merge
+ */
+void
+GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
+ const struct GNUNET_CONTAINER_MetaData *in)
+{
+ GNUNET_CONTAINER_meta_data_iterate (in, &merge_helper, md);
+}
+
+
+/**
* Remove an item.
*
* @param md metadata to manipulate
Modified: gnunet/src/util/pseudonym.c
===================================================================
--- gnunet/src/util/pseudonym.c 2010-04-28 07:58:12 UTC (rev 11085)
+++ gnunet/src/util/pseudonym.c 2010-04-28 08:07:19 UTC (rev 11086)
@@ -539,38 +539,6 @@
/**
- * Insert metadata into existing MD record (passed as cls).
- *
- * @param cls metadata to add to
- * @param plugin_name name of the plugin that generated the meta data
- * @param type type of entry to insert
- * @param format format of data
- * @param data_mime_type mime type of data
- * @param data value of the meta data
- * @param data_len number of bytes in data
- * @return always 0
- */
-static int
-merge_meta_helper (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
-{
- struct GNUNET_CONTAINER_MetaData *meta = cls;
-
- (void) GNUNET_CONTAINER_meta_data_insert (meta, plugin_name,
- type, format,
- data_mime_type,
- data, data_len);
- return 0;
-}
-
-
-
-/**
* Add a pseudonym to the set of known pseudonyms.
* For all pseudonym advertisements that we discover
* FS should automatically call this function.
@@ -597,7 +565,7 @@
if ((0 == STAT (fn, &sbuf)) &&
(GNUNET_OK == read_info (cfg, id, &old, &ranking, &name)))
{
- GNUNET_CONTAINER_meta_data_iterate (meta, &merge_meta_helper, old);
+ GNUNET_CONTAINER_meta_data_merge (old, meta);
write_pseudonym_info (cfg, id, old, ranking, name);
GNUNET_CONTAINER_meta_data_destroy (old);
GNUNET_free_non_null (name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11086 - in gnunet/src: fs include util,
gnunet <=