43 #define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
137 const char *data_mime_type,
const char *
data,
size_t data_len)
143 gfdc->
size = data_len;
188 const char *cdata =
data;
199 ((
size < 8 +
sizeof(uint32_t)) ||
210 mdSize = ntohl (mdSize);
211 if (mdSize >
size - 8 -
sizeof(uint32_t))
215 _ (
"MAGIC mismatch. This is not a GNUnet directory.\n"));
232 pos = 8 +
sizeof(uint32_t) + mdSize;
237 if (cdata[pos] ==
'\0')
255 while ((epos <
size) && (cdata[epos] !=
'\0'))
278 mdSize = ntohl (mdSize);
279 pos +=
sizeof(uint32_t);
280 if (pos + mdSize >
size)
299 full_data.
data = NULL;
433 slen = strlen (uris) + 1;
445 if ((slen +
sizeof(uint32_t) + mdxs - 1) /
DBLOCK_SIZE ==
459 serialized = (
char *) &
e[1];
462 sptr = &serialized[slen +
sizeof(uint32_t)];
474 e->len = slen +
sizeof(uint32_t) + mds;
487 do_align (
size_t start_position,
size_t end_position)
492 if ((start_position < align) && (end_position > align))
493 return align + end_position - start_position;
522 for (i = 0; i < count; i++)
525 badness = 0x7FFFFFFF;
527 for (j = i; j < count; j++)
530 cend = cpos + sizes[cval];
558 perm[i] = perm[best];
560 cpos += sizes[perm[i]];
609 for (i = 0; i < bld->
count; i++)
618 for (i = 0; i < bld->
count; i++)
621 size += sizes[perm[i]];
644 sptr = &
data[off +
sizeof(uint32_t)];
648 size - off -
sizeof(uint32_t),
655 off +=
sizeof(uint32_t) +
ret;
656 for (j = 0; j < bld->
count; j++)
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
shared definitions for the FS library
#define MAX_INLINE_SIZE
Maximum size for a file to be considered for inlining in a directory.
static int find_full_data(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_len)
Type of a function that libextractor calls for each meta data item found.
static size_t do_align(size_t start_position, size_t end_position)
Given the start and end position of a block of data, return the end position of that data after align...
#define GNUNET_DIRECTORY_MAGIC
String that is used to indicate that a file is a GNUnet directory.
static void block_align(size_t start, unsigned int count, const size_t *sizes, unsigned int *perm)
Compute a permutation of the blocks to minimize the cost of alignment.
static int ret
Return value of the commandline.
static int start
Set if we are to start default services (including ARM).
static struct Experiment * e
uint32_t data
The data value.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
static char * plugin_name
Name of our plugin.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
EXTRACTOR_MetaFormat
Format in which the extracted meta data is presented.
@ EXTRACTOR_METAFORMAT_BINARY
Some kind of binary format, see given Mime type.
@ EXTRACTOR_METAFORMAT_UTF8
0-terminated, UTF-8 encoded string.
EXTRACTOR_MetaType
Enumeration defining various sources of keywords.
@ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
@ EXTRACTOR_METATYPE_MIMETYPE
@ EXTRACTOR_METATYPE_GNUNET_FULL_DATA
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
int GNUNET_FS_directory_list_contents(size_t size, const void *data, uint64_t offset, GNUNET_FS_DirectoryEntryProcessor dep, void *dep_cls)
Iterate over all entries in a directory.
int GNUNET_FS_directory_builder_finish(struct GNUNET_FS_DirectoryBuilder *bld, size_t *rsize, void **rdata)
Finish building the directory.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_CONTAINER_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
#define GNUNET_FS_DIRECTORY_MAGIC
void GNUNET_FS_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *md, const void *data)
Add an entry to a directory.
#define GNUNET_FS_DIRECTORY_MIME
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
void GNUNET_FS_meta_data_make_directory(struct GNUNET_CONTAINER_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_CONTAINER_MetaData *mdir)
Create a directory builder.
int GNUNET_FS_uri_test_chk(const struct GNUNET_FS_Uri *uri)
Is this a file (or directory) URI?
struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_get_uri(const struct GNUNET_FS_Uri *uri)
Obtain the URI of the content itself.
void(* GNUNET_FS_DirectoryEntryProcessor)(void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, size_t length, const void *data)
Function used to process entries in a directory.
#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.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Entries in the directory (builder).
size_t len
Length of this entry.
struct BuilderEntry * next
This is a linked list.
Internal state of a directory builder.
struct GNUNET_CONTAINER_MetaData * meta
Meta-data for the directory itself.
struct BuilderEntry * head
Head of linked list of entries.
unsigned int count
Number of entries in the directory.
A Universal Resource Identifier (URI), opaque.
Closure for 'find_full_data'.
size_t size
Number of bytes stored in data.
void * data
Extracted binary meta data.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model