35#define MAX_META_DATA (1024 * 1024)
38#define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
80 enum EXTRACTOR_MetaType
type;
157 if (NULL == md->
sbuf)
256 enum EXTRACTOR_MetaType
type,
257 enum EXTRACTOR_MetaFormat
format,
258 const char *data_mime_type,
const char *
data,
265 if ((EXTRACTOR_METAFORMAT_UTF8 ==
format) ||
266 (EXTRACTOR_METAFORMAT_C_STRING ==
format))
276 if ((NULL == pos->
mime_type) && (NULL != data_mime_type))
281 if ((EXTRACTOR_METAFORMAT_C_STRING == pos->
format) &&
282 (EXTRACTOR_METAFORMAT_UTF8 ==
format))
284 pos->
format = EXTRACTOR_METAFORMAT_UTF8;
305 (NULL == data_mime_type) ? NULL :
GNUNET_strdup (data_mime_type);
310 if ((EXTRACTOR_METATYPE_FILENAME ==
type) ||
344 enum EXTRACTOR_MetaFormat
format,
const char *data_mime_type,
365 enum EXTRACTOR_MetaType
type,
399 EXTRACTOR_METATYPE_PUBLICATION_DATE,
403 EXTRACTOR_METATYPE_PUBLICATION_DATE,
404 EXTRACTOR_METAFORMAT_UTF8,
"text/plain",
405 dat, strlen (dat) + 1);
419 EXTRACTOR_MetaDataProcessor iter,
440 enum EXTRACTOR_MetaType
type)
448 ((pos->
format == EXTRACTOR_METAFORMAT_UTF8) ||
449 (pos->
format == EXTRACTOR_METAFORMAT_C_STRING)))
491 *md,
unsigned char **thumb)
502 (0 == strncasecmp (
"image/", pos->
mime_type, strlen (
"image/"))) &&
503 (EXTRACTOR_METAFORMAT_BINARY == pos->
format))
507 else if ((match->
type != EXTRACTOR_METATYPE_THUMBNAIL) &&
508 (pos->
type == EXTRACTOR_METATYPE_THUMBNAIL))
512 if ((NULL == match) || (0 == match->
data_size))
547#define HEADER_COMPRESSED 0x80000000
553#define HEADER_VERSION_MASK 0x7FFFFFFF
638 *md,
char **target,
size_t max,
667 if (NULL != md->
sbuf)
692 size = (size_t) msize;
709 ent[i].
type = htonl ((uint32_t) pos->
type);
723 if ((EXTRACTOR_METAFORMAT_UTF8 == pos->
format) ||
724 (EXTRACTOR_METAFORMAT_C_STRING == pos->
format))
750 if ((NULL == md->
sbuf) && (0 == i))
757 hdr->
size = htonl (left);
772 vmd->
sbuf = (
char *) hdr;
785 hdr->
size = htonl (left);
800 hdr->
size = htonl (left);
849 ihdr.
size = htonl (0);
864 if (NULL != md->
sbuf)
902 const char *meta_data;
904 const char *mime_type;
905 enum EXTRACTOR_MetaFormat
format;
922 dataSize = ntohl (hdr.
size);
965 for (i = 0; i < ic; i++)
970 if ((EXTRACTOR_METAFORMAT_UTF8 !=
format) &&
971 (EXTRACTOR_METAFORMAT_C_STRING !=
format) &&
972 (EXTRACTOR_METAFORMAT_BINARY !=
format))
986 meta_data = &mdata[left];
987 if ((EXTRACTOR_METAFORMAT_UTF8 ==
format) ||
988 (EXTRACTOR_METAFORMAT_C_STRING ==
format))
995 if (
'\0' != meta_data[dlen - 1])
1007 if ((plen > 0) && (
'\0' != mdata[left + plen - 1]))
1023 if ((mlen > 0) && (
'\0' != mdata[left + mlen - 1]))
1031 mime_type = &mdata[left];
1061 _ (
"metadata length"),
1073 "Serialized metadata `%s' larger than allowed (%u > %u)\n"),
1092 _ (
"Failed to deserialize metadata `%s'"), what);
1125 "Serialized %lld bytes of metadata",
1132 "Failed to serialize metadata `%s'",
1139 (uint32_t)
size)) ||
1230 .source = (
void *)
m,
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
static char * plugin_name
Name of our plugin.
static char * data
The data to insert into the dht.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static int result
Global testing status.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_SCHEDULER_Task * t
Main task.
API for file sharing via GNUnet.
enum GNUNET_GenericReturnValue GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read some contents into a buffer.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
enum GNUNET_GenericReturnValue GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
void GNUNET_BIO_read_set_error(struct GNUNET_BIO_ReadHandle *h, const char *emsg)
Set read error to handle.
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
enum GNUNET_GenericReturnValue GNUNET_FS_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const char *what, const struct GNUNET_FS_MetaData *m)
Write a metadata container.
enum GNUNET_GenericReturnValue GNUNET_FS_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_FS_MetaData **result)
Read a metadata container.
struct GNUNET_BIO_ReadSpec GNUNET_FS_read_spec_meta_data(const char *what, struct GNUNET_FS_MetaData **result)
Create the specification to read a metadata container.
struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data(const char *what, const struct GNUNET_FS_MetaData *m)
Create the specification to write a metadata container.
#define GNUNET_log(kind,...)
char * GNUNET_decompress(const char *input, size_t input_size, size_t output_size)
Decompress input, return the decompressed data as output.
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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
static unsigned int size
Size of the "table".
Handle for buffered reading.
Structure specifying a reading operation on an IO handle.
void * cls
Closure for rh.
const char * what
What is being read (for error message creation)
GNUNET_BIO_ReadHandler rh
Function performing data deserialization.
Handle for buffered writing.
Structure specifying a writing operation on an IO handle.
GNUNET_BIO_WriteHandler wh
Function performing data serialization.
size_t source_size
Size of source.
const char * what
What is being read (for error message creation)
Time for absolute times used by GNUnet, in microseconds.
Entry of serialized meta data.
uint32_t plugin_name_len
Number of bytes in the plugin name including 0-terminator.
uint32_t mime_type_len
Number of bytes in the mime type including 0-terminator.
uint32_t type
Meta data type.
uint32_t data_size
Number of bytes of meta data.
uint32_t format
Meta data format.