GNUnet  0.17.6
Data Structures | Macros | Functions
container_meta_data.c File Reference

Storing of meta data. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include <zlib.h>
Include dependency graph for container_meta_data.c:

Go to the source code of this file.

Data Structures

struct  MetaItem
 Meta data item. More...
 Meta data to associate with a file, directory or namespace. More...
struct  MetaDataHeader
 Header for serialized meta data. More...
struct  MetaDataEntry
 Entry of serialized meta data. More...


#define LOG(kind, ...)
#define HEADER_COMPRESSED   0x80000000
 Flag in 'version' that indicates compressed meta-data. More...
 Bits in 'version' that give the version number. More...


int GNUNET_try_compression (const char *data, size_t old_size, char **result, size_t *new_size)
 Try to compress the given block of data using libz. More...
char * GNUNET_decompress (const char *input, size_t input_size, size_t output_size)
 Decompress input, return the decompressed data as output. More...
struct GNUNET_CONTAINER_MetaDataGNUNET_CONTAINER_meta_data_create ()
 Create a fresh struct CONTAINER_MetaData token. More...
static void meta_item_free (struct MetaItem *mi)
 Free meta data item. More...
static void invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md)
 The meta data has changed, invalidate its serialization buffer. More...
void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md)
 Free meta data. More...
void GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md)
 Remove all items in the container. More...
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. More...
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. More...
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_size)
 Merge given meta data. More...
void GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, const struct GNUNET_CONTAINER_MetaData *in)
 Extend metadata. More...
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. More...
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. More...
int GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, EXTRACTOR_MetaDataProcessor iter, void *iter_cls)
 Iterate over MD entries. More...
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. More...
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. More...
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). More...
struct GNUNET_CONTAINER_MetaDataGNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData *md)
 Duplicate a struct GNUNET_CONTAINER_MetaData. More...
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. More...
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. More...
struct GNUNET_CONTAINER_MetaDataGNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
 Deserialize meta-data. More...

Detailed Description

Storing of meta data.

Christian Grothoff

Definition in file container_meta_data.c.

Macro Definition Documentation


#define LOG (   kind,
GNUNET_log_from (kind, "util-container-meta-data", \
#define GNUNET_log_from(kind, comp,...)

Definition at line 34 of file container_meta_data.c.


#define HEADER_COMPRESSED   0x80000000

Flag in 'version' that indicates compressed meta-data.

Definition at line 626 of file container_meta_data.c.



Bits in 'version' that give the version number.

Definition at line 632 of file container_meta_data.c.

Function Documentation

◆ meta_item_free()

static void meta_item_free ( struct MetaItem mi)

Free meta data item.

miitem to free

Definition at line 218 of file container_meta_data.c.

219 {
220  GNUNET_free (mi->plugin_name);
221  GNUNET_free (mi->mime_type);
222  GNUNET_free (mi->data);
223  GNUNET_free (mi);
224 }
#define GNUNET_free(ptr)
Wrapper around free.
char * mime_type
Mime-type of data.
char * data
The actual meta data.
char * plugin_name
Name of the extracting plugin.

References MetaItem::data, GNUNET_free, MetaItem::mime_type, and MetaItem::plugin_name.

Referenced by GNUNET_CONTAINER_meta_data_clear(), GNUNET_CONTAINER_meta_data_delete(), and GNUNET_CONTAINER_meta_data_destroy().

Here is the caller graph for this function:

◆ invalidate_sbuf()

static void invalidate_sbuf ( struct GNUNET_CONTAINER_MetaData md)

The meta data has changed, invalidate its serialization buffer.

mdmeta data that changed

Definition at line 234 of file container_meta_data.c.

235 {
236  if (NULL == md->sbuf)
237  return;
238  GNUNET_free (md->sbuf);
239  md->sbuf = NULL;
240  md->sbuf_size = 0;
241 }
char * sbuf
Complete serialized and compressed buffer of the items.
size_t sbuf_size
Number of bytes in 'sbuf'.

References GNUNET_free, GNUNET_CONTAINER_MetaData::sbuf, and GNUNET_CONTAINER_MetaData::sbuf_size.

Referenced by GNUNET_CONTAINER_meta_data_delete(), and GNUNET_CONTAINER_meta_data_insert().

Here is the caller graph for this function:

◆ merge_helper()

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_size 

Merge given meta data.

clsthe struct GNUNET_CONTAINER_MetaData to merge into
plugin_namename 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).
typelibextractor-type describing the meta data
formatbasic format information about data
data_mime_typemime-type of data (not of the original file); can be NULL (if mime-type is not known)
dataactual meta-data found
data_sizenumber of bytes in data
0 (to continue)

Definition at line 422 of file container_meta_data.c.

425 {
426  struct GNUNET_CONTAINER_MetaData *md = cls;
429  data_mime_type, data, data_size);
430  return 0;
431 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t data
The data value.
static char * plugin_name
Name of our plugin.
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.
Meta data to associate with a file, directory or namespace.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References data, data_size, GNUNET_CONTAINER_meta_data_insert(), plugin_name, and type.

Referenced by GNUNET_CONTAINER_meta_data_merge().

Here is the call graph for this function:
Here is the caller graph for this function: