![]() |
GNUnet
0.11.x
|
GNU libextractor key-value pairs. More...
Enumerations | |
enum | GNUNET_CONTAINER_MetaDataSerializationOptions { GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0, GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1, GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2 } |
Options for metadata serialization. More... | |
GNU libextractor key-value pairs.
Options for metadata serialization.
Definition at line 632 of file gnunet_container_lib.h.
struct GNUNET_CONTAINER_MetaData* GNUNET_CONTAINER_meta_data_create | ( | void | ) |
Create a fresh meta data container.
Create a fresh meta data container.
Definition at line 206 of file container_meta_data.c.
References GNUNET_new.
Referenced by extract_files(), get_file_information(), getopt_set_metadata(), GNUNET_CONTAINER_meta_data_deserialize(), GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_FS_directory_builder_create(), GNUNET_FS_file_information_create_from_reader(), migrate_and_drop_metadata(), process_kblock(), and share_tree_trim().
struct GNUNET_CONTAINER_MetaData* GNUNET_CONTAINER_meta_data_duplicate | ( | const struct GNUNET_CONTAINER_MetaData * | md | ) |
Duplicate a MetaData token.
md | what to duplicate |
Duplicate a MetaData token.
md | what to duplicate |
Definition at line 670 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_insert(), GNUNET_CONTAINER_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_CONTAINER_meta_data_destroy | ( | struct GNUNET_CONTAINER_MetaData * | md | ) |
Free meta data.
md | what to free |
Definition at line 250 of file container_meta_data.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_CONTAINER_MetaData::items_head, GNUNET_CONTAINER_MetaData::items_tail, meta_item_free(), and GNUNET_CONTAINER_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_CONTAINER_meta_data_test_equal | ( | const struct GNUNET_CONTAINER_MetaData * | md1, |
const struct GNUNET_CONTAINER_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 299 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_NO, GNUNET_YES, GNUNET_CONTAINER_MetaData::item_count, GNUNET_CONTAINER_MetaData::items_head, MetaItem::next, and MetaItem::type.
int GNUNET_CONTAINER_meta_data_insert | ( | struct GNUNET_CONTAINER_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 (i.e. '<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 (i.e. '<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 353 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METAFORMAT_UTF8, EXTRACTOR_METATYPE_FILENAME, 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_CONTAINER_MetaData::item_count, GNUNET_CONTAINER_MetaData::items_head, GNUNET_CONTAINER_MetaData::items_tail, MetaItem::mime_type, MetaItem::next, p, MetaItem::plugin_name, MetaItem::prev, and MetaItem::type.
Referenced by getopt_set_metadata(), GNUNET_CONTAINER_meta_data_add_publication_date(), GNUNET_CONTAINER_meta_data_deserialize(), GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_FS_directory_builder_add(), GNUNET_FS_file_information_create_from_file(), GNUNET_FS_meta_data_make_directory(), merge_helper(), migrate_and_drop_metadata(), process_helper_msgs(), and share_tree_trim().
void GNUNET_CONTAINER_meta_data_merge | ( | struct GNUNET_CONTAINER_MetaData * | md, |
const struct GNUNET_CONTAINER_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 462 of file container_meta_data.c.
References GNUNET_CONTAINER_meta_data_iterate(), and merge_helper().
Referenced by process_ksk_result(), and publish_inspector().
int GNUNET_CONTAINER_meta_data_delete | ( | struct GNUNET_CONTAINER_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 |
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 480 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, GNUNET_CONTAINER_DLL_remove, GNUNET_OK, GNUNET_SYSERR, invalidate_sbuf(), GNUNET_CONTAINER_MetaData::item_count, GNUNET_CONTAINER_MetaData::items_head, GNUNET_CONTAINER_MetaData::items_tail, meta_item_free(), MetaItem::next, and MetaItem::type.
Referenced by get_file_information(), GNUNET_CONTAINER_meta_data_add_publication_date(), and process_helper_msgs().
void GNUNET_CONTAINER_meta_data_clear | ( | struct GNUNET_CONTAINER_MetaData * | md | ) |
Remove all items in the container.
md | metadata to manipulate |
Definition at line 272 of file container_meta_data.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_CONTAINER_MetaData::items_head, GNUNET_CONTAINER_MetaData::items_tail, meta_item_free(), and GNUNET_CONTAINER_MetaData::sbuf.
void GNUNET_CONTAINER_meta_data_add_publication_date | ( | struct GNUNET_CONTAINER_MetaData * | md | ) |
Add the current time as the publication date to the meta-data.
md | metadata to modify |
Definition at line 513 of file container_meta_data.c.
References EXTRACTOR_METAFORMAT_UTF8, EXTRACTOR_METATYPE_PUBLICATION_DATE, GNUNET_CONTAINER_meta_data_delete(), GNUNET_CONTAINER_meta_data_insert(), GNUNET_STRINGS_absolute_time_to_string(), and GNUNET_TIME_absolute_get().
Referenced by publish_inspector().
int GNUNET_CONTAINER_meta_data_iterate | ( | const struct GNUNET_CONTAINER_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 540 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaItem::format, GNUNET_CONTAINER_MetaData::item_count, GNUNET_CONTAINER_MetaData::items_head, MetaItem::mime_type, MetaItem::next, MetaItem::plugin_name, and MetaItem::type.
Referenced by GNUNET_CONTAINER_meta_data_merge(), GNUNET_FS_directory_list_contents(), GNUNET_FS_download_start_task_(), GNUNET_FS_uri_ksk_create_from_meta_data(), print_entry(), progress_cb(), publish_inspector(), and share_tree_trim().
char* GNUNET_CONTAINER_meta_data_get_by_type | ( | const struct GNUNET_CONTAINER_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 570 of file container_meta_data.c.
References MetaItem::data, EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METAFORMAT_UTF8, MetaItem::format, GNUNET_strdup, GNUNET_CONTAINER_MetaData::items_head, MetaItem::next, and MetaItem::type.
Referenced by GNUNET_CONTAINER_meta_data_get_first_by_types(), GNUNET_FS_directory_list_contents(), 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(), progress_cb(), and publish_inspector().
char* GNUNET_CONTAINER_meta_data_get_first_by_types | ( | const struct GNUNET_CONTAINER_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 599 of file container_meta_data.c.
References gnunet-chk::args, GNUNET_CONTAINER_meta_data_get_by_type(), ret, and MetaItem::type.
Referenced by GNUNET_FS_meta_data_suggest_filename(), and GNUNET_FS_uri_ksk_create_from_meta_data().
size_t GNUNET_CONTAINER_meta_data_get_thumbnail | ( | const struct GNUNET_CONTAINER_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 633 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, EXTRACTOR_METAFORMAT_BINARY, EXTRACTOR_METATYPE_THUMBNAIL, MetaItem::format, GNUNET_malloc, GNUNET_memcpy, GNUNET_CONTAINER_MetaData::items_head, MetaItem::mime_type, MetaItem::next, and MetaItem::type.
ssize_t GNUNET_CONTAINER_meta_data_serialize | ( | const struct GNUNET_CONTAINER_MetaData * | md, |
char ** | target, | ||
size_t | max, | ||
enum GNUNET_CONTAINER_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 780 of file container_meta_data.c.
References MetaItem::data, MetaItem::data_size, MetaDataEntry::data_size, MetaDataHeader::entries, EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METAFORMAT_UTF8, MetaItem::format, MetaDataEntry::format, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS, GNUNET_CONTAINER_META_DATA_SERIALIZE_PART, GNUNET_free, GNUNET_malloc, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_SYSERR, GNUNET_try_compression(), GNUNET_YES, HEADER_COMPRESSED, GNUNET_CONTAINER_MetaData::item_count, GNUNET_CONTAINER_MetaData::items_head, GNUNET_CONTAINER_MetaData::items_tail, MetaItem::mime_type, MetaDataEntry::mime_type_len, MetaItem::next, MetaItem::plugin_name, MetaDataEntry::plugin_name_len, MetaItem::prev, GNUNET_CONTAINER_MetaData::sbuf, GNUNET_CONTAINER_MetaData::sbuf_size, size, MetaDataHeader::size, MetaItem::type, MetaDataEntry::type, and MetaDataHeader::version.
Referenced by extract_files(), GNUNET_BIO_write_meta_data(), GNUNET_CONTAINER_meta_data_get_serialized_size(), GNUNET_FS_directory_builder_add(), GNUNET_FS_directory_builder_finish(), and GNUNET_FS_publish_ublock_().
ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size | ( | const struct GNUNET_CONTAINER_MetaData * | md | ) |
Get the size of the full meta-data in serialized form.
md | metadata to inspect |
Definition at line 1004 of file container_meta_data.c.
References GNUNET_CONTAINER_meta_data_serialize(), GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL, GNUNET_free, GNUNET_MAX_MALLOC_CHECKED, ret, GNUNET_CONTAINER_MetaData::sbuf, and GNUNET_CONTAINER_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_CONTAINER_MetaData* GNUNET_CONTAINER_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 1031 of file container_meta_data.c.
References MetaItem::data, MetaDataEntry::data_size, MetaDataHeader::entries, EXTRACTOR_METAFORMAT_BINARY, EXTRACTOR_METAFORMAT_C_STRING, EXTRACTOR_METAFORMAT_UTF8, MetaItem::format, MetaDataEntry::format, GNUNET_break_op, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_insert(), GNUNET_decompress(), GNUNET_free, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, HEADER_COMPRESSED, HEADER_VERSION_MASK, MetaItem::mime_type, MetaDataEntry::mime_type_len, MetaItem::plugin_name, MetaDataEntry::plugin_name_len, MetaDataHeader::size, MetaDataEntry::type, and MetaDataHeader::version.
Referenced by GNUNET_BIO_read_meta_data(), GNUNET_FS_directory_list_contents(), process_helper_msgs(), process_kblock(), and process_sblock().