}
else
{
- /* FIXME: consider combining the meta data */
+ GNUNET_CONTAINER_meta_data_merge (sr->meta, meta);
}
/* check if mandatory satisfied */
if (ent->mandatory)
}
-/**
- * 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
}
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;
}
size_t data_len);
+/**
+ * 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.
*
}
+/**
+ * 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.
*
}
-/**
- * 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
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);