38 #define MAX_META_DATA (1024 * 1024)
41 #define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
84 enum EXTRACTOR_MetaType
type;
89 enum EXTRACTOR_MetaFormat
format;
161 if (NULL == md->
sbuf)
260 enum EXTRACTOR_MetaType
type,
261 enum EXTRACTOR_MetaFormat
format,
262 const char *data_mime_type,
const char *
data,
269 if ((EXTRACTOR_METAFORMAT_UTF8 ==
format) ||
270 (EXTRACTOR_METAFORMAT_C_STRING ==
format))
280 if ((NULL == pos->
mime_type) && (NULL != data_mime_type))
285 if ((EXTRACTOR_METAFORMAT_C_STRING == pos->
format) &&
286 (EXTRACTOR_METAFORMAT_UTF8 ==
format))
288 pos->
format = EXTRACTOR_METAFORMAT_UTF8;
309 (NULL == data_mime_type) ? NULL :
GNUNET_strdup (data_mime_type);
314 if ((EXTRACTOR_METATYPE_FILENAME ==
type) ||
348 enum EXTRACTOR_MetaFormat
format,
const char *data_mime_type,
369 enum EXTRACTOR_MetaType
type,
403 EXTRACTOR_METATYPE_PUBLICATION_DATE,
407 EXTRACTOR_METATYPE_PUBLICATION_DATE,
408 EXTRACTOR_METAFORMAT_UTF8,
"text/plain",
409 dat, strlen (dat) + 1);
423 EXTRACTOR_MetaDataProcessor iter,
444 enum EXTRACTOR_MetaType
type)
452 ((pos->
format == EXTRACTOR_METAFORMAT_UTF8) ||
453 (pos->
format == EXTRACTOR_METAFORMAT_C_STRING)))
495 *md,
unsigned char **thumb)
506 (0 == strncasecmp (
"image/", pos->
mime_type, strlen (
"image/"))) &&
507 (EXTRACTOR_METAFORMAT_BINARY == pos->
format))
511 else if ((match->
type != EXTRACTOR_METATYPE_THUMBNAIL) &&
512 (pos->
type == EXTRACTOR_METATYPE_THUMBNAIL))
516 if ((NULL == match) || (0 == match->
data_size))
551 #define HEADER_COMPRESSED 0x80000000
557 #define HEADER_VERSION_MASK 0x7FFFFFFF
642 *md,
char **target,
size_t max,
671 if (NULL != md->
sbuf)
696 size = (size_t) msize;
713 ent[i].
type = htonl ((uint32_t) pos->
type);
727 if ((EXTRACTOR_METAFORMAT_UTF8 == pos->
format) ||
728 (EXTRACTOR_METAFORMAT_C_STRING == pos->
format))
754 if ((NULL == md->
sbuf) && (0 == i))
761 hdr->
size = htonl (left);
776 vmd->
sbuf = (
char *) hdr;
789 hdr->
size = htonl (left);
804 hdr->
size = htonl (left);
853 ihdr.
size = htonl (0);
868 if (NULL != md->
sbuf)
906 const char *meta_data;
908 const char *mime_type;
909 enum EXTRACTOR_MetaFormat
format;
926 dataSize = ntohl (hdr.
size);
969 for (i = 0; i < ic; i++)
973 format = (
enum EXTRACTOR_MetaFormat) ntohl (ent.
format);
974 if ((EXTRACTOR_METAFORMAT_UTF8 !=
format) &&
975 (EXTRACTOR_METAFORMAT_C_STRING !=
format) &&
976 (EXTRACTOR_METAFORMAT_BINARY !=
format))
990 meta_data = &mdata[left];
991 if ((EXTRACTOR_METAFORMAT_UTF8 ==
format) ||
992 (EXTRACTOR_METAFORMAT_C_STRING ==
format))
999 if (
'\0' != meta_data[dlen - 1])
1011 if ((plen > 0) && (
'\0' != mdata[left + plen - 1]))
1027 if ((mlen > 0) && (
'\0' != mdata[left + mlen - 1]))
1035 mime_type = &mdata[left];
1037 (
enum EXTRACTOR_MetaType)
1064 _ (
"metadata length"),
1076 "Serialized metadata `%s' larger than allowed (%u > %u)\n"),
1095 _ (
"Failed to deserialize metadata `%s'"), what);
1127 _ (
"Serialized %ld bytes of metadata"),
1134 _ (
"Failed to serialize metadata `%s'"),
1139 _ (
"metadata length"),
1224 .source = (
void *)
m,
static int ret
Return value of the commandline.
static size_t data_size
Number of bytes in data.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
uint32_t data
The data value.
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static int result
Global testing status.
static char * plugin_name
Name of our plugin.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_SCHEDULER_Task * t
Main task.
API for file sharing via GNUnet.
int GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
void GNUNET_BIO_read_set_error(struct GNUNET_BIO_ReadHandle *h, const char *emsg)
Set read error to handle.
int GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read some contents into a buffer.
#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.
int 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.
char * GNUNET_decompress(const char *input, size_t input_size, size_t output_size)
Decompress input, return the decompressed data as output.
#define GNUNET_log(kind,...)
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.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model