Meta data processingGNU libextractor key-value pairs. More...
Enumerations | |
enum | GNUNET_FS_MetaDataSerializationOptions { GNUNET_FS_META_DATA_SERIALIZE_FULL = 0 , GNUNET_FS_META_DATA_SERIALIZE_PART = 1 , GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS = 2 } |
Options for metadata serialization. More... | |
Functions | |
struct GNUNET_FS_MetaData * | GNUNET_FS_meta_data_create (void) |
Create a fresh meta data container. More... | |
struct GNUNET_FS_MetaData * | GNUNET_FS_meta_data_duplicate (const struct GNUNET_FS_MetaData *md) |
Duplicate a MetaData token. More... | |
void | GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md) |
Free meta data. More... | |
int | GNUNET_FS_meta_data_test_equal (const struct GNUNET_FS_MetaData *md1, const struct GNUNET_FS_MetaData *md2) |
Test if two MDs are equal. More... | |
int | GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_size) |
Extend metadata. More... | |
void | GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md, const struct GNUNET_FS_MetaData *in) |
Extend metadata. More... | |
int | GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type, const char *data, size_t data_size) |
Remove an item. More... | |
void | GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md) |
Remove all items in the container. More... | |
void | GNUNET_FS_meta_data_add_publication_date (struct GNUNET_FS_MetaData *md) |
Add the current time as the publication date to the meta-data. More... | |
int | GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls) |
Iterate over MD entries. More... | |
char * | GNUNET_FS_meta_data_get_by_type (const struct GNUNET_FS_MetaData *md, enum EXTRACTOR_MetaType type) |
Get the first MD entry of the given type. More... | |
char * | GNUNET_FS_meta_data_get_first_by_types (const struct GNUNET_FS_MetaData *md,...) |
Get the first matching MD entry of the given types. More... | |
size_t | GNUNET_FS_meta_data_get_thumbnail (const struct GNUNET_FS_MetaData *md, unsigned char **thumb) |
Get a thumbnail from the meta-data (if present). More... | |
ssize_t | GNUNET_FS_meta_data_serialize (const struct GNUNET_FS_MetaData *md, char **target, size_t max, enum GNUNET_FS_MetaDataSerializationOptions opt) |
Serialize meta-data to target. More... | |
ssize_t | GNUNET_FS_meta_data_get_serialized_size (const struct GNUNET_FS_MetaData *md) |
Get the size of the full meta-data in serialized form. More... | |
struct GNUNET_FS_MetaData * | GNUNET_FS_meta_data_deserialize (const char *input, size_t size) |
Deserialize meta-data. More... | |
Meta data processing
GNU libextractor key-value pairs.
Options for metadata serialization.
Definition at line 3113 of file gnunet_fs_service.h.
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_create | ( | void | ) |
Create a fresh meta data container.
Create a fresh meta data container.
Definition at line 127 of file meta_data.c.
References GNUNET_new.
Referenced by extract_files(), get_file_information(), getopt_set_metadata(), GNUNET_FS_directory_builder_create(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_meta_data_deserialize(), GNUNET_FS_meta_data_duplicate(), migrate_and_drop_metadata(), process_kblock(), and share_tree_trim().
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_duplicate | ( | const struct GNUNET_FS_MetaData * | md | ) |
Duplicate a MetaData token.
md | what to duplicate |
Duplicate a MetaData token.
md | what to duplicate |
Definition at line 527 of file meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_insert(), GNUNET_FS_MetaData::items_tail, MetaItem::mime_type, MetaItem::plugin_name, MetaItem::prev, ret, and MetaItem::type.
Referenced by create_download_context(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_create(), GNUNET_FS_file_information_create_empty_directory(), GNUNET_FS_file_information_create_from_reader(), GNUNET_FS_probe(), GNUNET_FS_publish_ksk(), GNUNET_FS_publish_sks(), process_ksk_result(), and process_sks_result().
void GNUNET_FS_meta_data_destroy | ( | struct GNUNET_FS_MetaData * | md | ) |
Free meta data.
md | what to free |
Definition at line 166 of file meta_data.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_MetaData::items_head, GNUNET_FS_MetaData::items_tail, meta_item_free(), and GNUNET_FS_MetaData::sbuf.
Referenced by deserialize_search_result(), do_stop_task(), extract_files(), free_download_context(), free_result(), free_update_information_graph(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_finish(), GNUNET_FS_directory_list_contents(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_stop(), GNUNET_FS_file_information_destroy(), GNUNET_FS_probe_stop(), GNUNET_FS_publish_ksk_cancel(), GNUNET_FS_publish_sks_cancel(), GNUNET_FS_share_tree_free(), process_kblock(), process_sblock(), publish_inspector(), read_update_information_graph(), search_result_free(), and search_result_suspend().
int GNUNET_FS_meta_data_test_equal | ( | const struct GNUNET_FS_MetaData * | md1, |
const struct GNUNET_FS_MetaData * | md2 | ||
) |
Test if two MDs are equal.
We consider them equal if the meta types, formats and content match (we do not include the mime types and plugins names in this consideration).
md1 | first value to check |
md2 | other value to check |
Definition at line 200 of file meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_NO, GNUNET_YES, GNUNET_FS_MetaData::item_count, GNUNET_FS_MetaData::items_head, MetaItem::next, and MetaItem::type.
int GNUNET_FS_meta_data_insert | ( | struct GNUNET_FS_MetaData * | md, |
const char * | plugin_name, | ||
enum EXTRACTOR_MetaType | type, | ||
enum EXTRACTOR_MetaFormat | format, | ||
const char * | data_mime_type, | ||
const char * | data, | ||
size_t | data_size | ||
) |
Extend metadata.
md | metadata to extend |
plugin_name | name of the plugin that produced this value; special values can be used (e.g. '<zlib>' for zlib being used in the main libextractor library and yielding meta data). |
type | libextractor-type describing the meta data |
format | basic format information about data |
data_mime_type | mime-type of data (not of the original file); can be NULL (if mime-type is not known) |
data | actual meta-data found |
data_size | number of bytes in data |
Note that the list of meta data items is sorted by size (largest first).
md | metadata to extend |
plugin_name | name of the plugin that produced this value; special values can be used (e.g. '<zlib>' for zlib being used in the main libextractor library and yielding meta data). |
type | libextractor-type describing the meta data |
format | basic format information about data |
data_mime_type | mime-type of data (not of the original file); can be NULL (if mime-type is not known) |
data | actual meta-data found |
data_size | number of bytes in data |
Definition at line 254 of file meta_data.c.
References data, MetaItem::data, data_size, MetaItem::data_size, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, MetaItem::format, GNUNET_break, GNUNET_CONTAINER_DLL_insert_after, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, invalidate_sbuf(), GNUNET_FS_MetaData::item_count, GNUNET_FS_MetaData::items_head, GNUNET_FS_MetaData::items_tail, MetaItem::mime_type, MetaItem::next, p, plugin_name, MetaItem::plugin_name, MetaItem::prev, type, and MetaItem::type.
Referenced by getopt_set_metadata(), GNUNET_FS_directory_builder_add(), GNUNET_FS_file_information_create_from_file(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_FS_meta_data_deserialize(), GNUNET_FS_meta_data_duplicate(), GNUNET_FS_meta_data_make_directory(), merge_helper(), migrate_and_drop_metadata(), process_helper_msgs(), and share_tree_trim().
void GNUNET_FS_meta_data_merge | ( | struct GNUNET_FS_MetaData * | md, |
const struct GNUNET_FS_MetaData * | in | ||
) |
Extend metadata.
Merges the meta data from the second argument into the first, discarding duplicate key-value pairs.
md | metadata to extend |
in | metadata to merge |
Definition at line 356 of file meta_data.c.
References GNUNET_FS_meta_data_iterate(), and merge_helper().
Referenced by process_ksk_result(), and publish_inspector().
int GNUNET_FS_meta_data_delete | ( | struct GNUNET_FS_MetaData * | md, |
enum EXTRACTOR_MetaType | type, | ||
const char * | data, | ||
size_t | data_size | ||
) |
Remove an item.
md | metadata to manipulate |
type | type of the item to remove |
data | specific value to remove, NULL to remove all entries of the given type |
data_size | number of bytes in data |
Definition at line 364 of file meta_data.c.
References data, MetaItem::data, data_size, MetaItem::data_size, GNUNET_CONTAINER_DLL_remove, GNUNET_OK, GNUNET_SYSERR, invalidate_sbuf(), GNUNET_FS_MetaData::item_count, GNUNET_FS_MetaData::items_head, GNUNET_FS_MetaData::items_tail, meta_item_free(), MetaItem::next, type, and MetaItem::type.
Referenced by get_file_information(), GNUNET_FS_meta_data_add_publication_date(), and process_helper_msgs().
void GNUNET_FS_meta_data_clear | ( | struct GNUNET_FS_MetaData * | md | ) |
Remove all items in the container.
md | metadata to manipulate |
Definition at line 183 of file meta_data.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_FS_MetaData::items_head, GNUNET_FS_MetaData::items_tail, meta_item_free(), and GNUNET_FS_MetaData::sbuf.
void GNUNET_FS_meta_data_add_publication_date | ( | struct GNUNET_FS_MetaData * | md | ) |
Add the current time as the publication date to the meta-data.
md | metadata to modify |
Definition at line 391 of file meta_data.c.
References GNUNET_FS_meta_data_delete(), GNUNET_FS_meta_data_insert(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), and t.
Referenced by publish_inspector().
int GNUNET_FS_meta_data_iterate | ( | const struct GNUNET_FS_MetaData * | md, |
EXTRACTOR_MetaDataProcessor | iter, | ||
void * | iter_cls | ||
) |
Iterate over MD entries.
md | metadata to inspect |
iter | function to call on each entry, return 0 to continue to iterate and 1 to abort iteration in this function (GNU libextractor API!) |
iter_cls | closure for iter |
md | metadata to inspect |
iter | function to call on each entry |
iter_cls | closure for iterator |
Definition at line 418 of file meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_FS_MetaData::item_count, GNUNET_FS_MetaData::items_head, MetaItem::mime_type, MetaItem::next, MetaItem::plugin_name, and MetaItem::type.
Referenced by GNUNET_FS_directory_list_contents(), GNUNET_FS_download_start_task_(), GNUNET_FS_meta_data_merge(), GNUNET_FS_uri_ksk_create_from_meta_data(), print_entry(), print_search_result(), publish_inspector(), and share_tree_trim().
char * GNUNET_FS_meta_data_get_by_type | ( | const struct GNUNET_FS_MetaData * | md, |
enum EXTRACTOR_MetaType | type | ||
) |
Get the first MD entry of the given type.
Caller is responsible for freeing the return value. Also, only meta data items that are strings (0-terminated) are returned by this function.
md | metadata to inspect |
type | type to look for |
Definition at line 438 of file meta_data.c.
References MetaItem::data, MetaItem::format, GNUNET_strdup, GNUNET_FS_MetaData::items_head, MetaItem::next, type, and MetaItem::type.
Referenced by GNUNET_FS_directory_list_contents(), GNUNET_FS_meta_data_get_first_by_types(), GNUNET_FS_meta_data_make_directory(), GNUNET_FS_meta_data_suggest_filename(), GNUNET_FS_meta_data_test_for_directory(), GNUNET_FS_publish_main_(), print_entry(), print_search_result(), progress_cb(), and publish_inspector().
char * GNUNET_FS_meta_data_get_first_by_types | ( | const struct GNUNET_FS_MetaData * | md, |
... | |||
) |
Get the first matching MD entry of the given types.
Caller is responsible for freeing the return value. Also, only meta data items that are strings (0-terminated) are returned by this function.
md | metadata to inspect |
... | -1-terminated list of types |
Definition at line 456 of file meta_data.c.
References consensus-simulation::args, GNUNET_FS_meta_data_get_by_type(), ret, and type.
Referenced by GNUNET_FS_meta_data_suggest_filename(), and GNUNET_FS_uri_ksk_create_from_meta_data().
size_t GNUNET_FS_meta_data_get_thumbnail | ( | const struct GNUNET_FS_MetaData * | md, |
unsigned char ** | thumb | ||
) |
Get a thumbnail from the meta-data (if present).
Only matches meta data with mime type "image" and binary format.
md | metadata to inspect |
thumb | will be set to the thumbnail data. Must be freed by the caller! |
md | metadata to get the thumbnail from |
thumb | will be set to the thumbnail data. Must be freed by the caller! |
Definition at line 490 of file meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_malloc, GNUNET_memcpy, GNUNET_FS_MetaData::items_head, MetaItem::mime_type, MetaItem::next, and MetaItem::type.
ssize_t GNUNET_FS_meta_data_serialize | ( | const struct GNUNET_FS_MetaData * | md, |
char ** | target, | ||
size_t | max, | ||
enum GNUNET_FS_MetaDataSerializationOptions | opt | ||
) |
Serialize meta-data to target.
md | metadata to serialize |
target | where to write the serialized metadata; *target can be NULL, in which case memory is allocated |
max | maximum number of bytes available |
opt | is it ok to just write SOME of the meta-data to match the size constraint, possibly discarding some data? |
md | metadata to serialize |
target | where to write the serialized metadata; *target can be NULL, in which case memory is allocated |
max | maximum number of bytes available in target |
opt | is it ok to just write SOME of the meta-data to match the size constraint, possibly discarding some data? |
Definition at line 637 of file meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaDataEntry::data_size, MetaDataHeader::entries, MetaItem::format, MetaDataEntry::format, GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS, GNUNET_FS_META_DATA_SERIALIZE_PART, GNUNET_malloc, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_SYSERR, GNUNET_try_compression(), GNUNET_YES, HEADER_COMPRESSED, GNUNET_FS_MetaData::item_count, GNUNET_FS_MetaData::items_head, GNUNET_FS_MetaData::items_tail, max, MetaItem::mime_type, MetaDataEntry::mime_type_len, MetaItem::next, MetaItem::plugin_name, MetaDataEntry::plugin_name_len, MetaItem::prev, GNUNET_FS_MetaData::sbuf, GNUNET_FS_MetaData::sbuf_size, size, MetaDataHeader::size, MetaItem::type, MetaDataEntry::type, and MetaDataHeader::version.
Referenced by extract_files(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_finish(), GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_publish_ublock_(), and GNUNET_FS_write_meta_data().
ssize_t GNUNET_FS_meta_data_get_serialized_size | ( | const struct GNUNET_FS_MetaData * | md | ) |
Get the size of the full meta-data in serialized form.
md | metadata to inspect |
Definition at line 858 of file meta_data.c.
References GNUNET_free, GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_FULL, GNUNET_MAX_MALLOC_CHECKED, ret, GNUNET_FS_MetaData::sbuf, and GNUNET_FS_MetaData::sbuf_size.
Referenced by extract_files(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_finish(), GNUNET_FS_download_start_task_(), GNUNET_FS_publish_ublock_(), and trigger_recursive_download().
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_deserialize | ( | const char * | input, |
size_t | size | ||
) |
Deserialize meta-data.
Initializes md.
input | serialized meta-data. |
size | number of bytes available |
Initializes md.
input | buffer with the serialized metadata |
size | number of bytes available in input |
Definition at line 885 of file meta_data.c.
References data, MetaDataEntry::data_size, MetaDataHeader::entries, MetaDataEntry::format, GNUNET_break_op, GNUNET_decompress(), GNUNET_free, GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_insert(), GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, HEADER_COMPRESSED, HEADER_VERSION_MASK, MetaDataEntry::mime_type_len, plugin_name, MetaDataEntry::plugin_name_len, size, MetaDataHeader::size, MetaDataEntry::type, and MetaDataHeader::version.
Referenced by GNUNET_FS_directory_list_contents(), GNUNET_FS_read_meta_data(), process_helper_msgs(), process_kblock(), and process_sblock().