44#define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
64 EXTRACTOR_METATYPE_MIMETYPE);
94 EXTRACTOR_METATYPE_MIMETYPE,
95 EXTRACTOR_METAFORMAT_UTF8,
"text/plain",
137 enum EXTRACTOR_MetaType
type,
enum EXTRACTOR_MetaFormat format,
138 const char *data_mime_type,
const char *
data,
size_t data_len)
142 if (
type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
144 gfdc->
size = data_len;
189 const char *cdata =
data;
200 ((
size < 8 +
sizeof(uint32_t)) ||
211 mdSize = ntohl (mdSize);
212 if (mdSize >
size - 8 -
sizeof(uint32_t))
216 _ (
"MAGIC mismatch. This is not a GNUnet directory.\n"));
233 pos = 8 +
sizeof(uint32_t) + mdSize;
238 if (cdata[pos] ==
'\0')
256 while ((epos <
size) && (cdata[epos] !=
'\0'))
279 mdSize = ntohl (mdSize);
280 pos +=
sizeof(uint32_t);
281 if (pos + mdSize >
size)
300 full_data.
data = NULL;
434 slen = strlen (uris) + 1;
442 EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
443 EXTRACTOR_METAFORMAT_BINARY, NULL,
data,
446 if ((slen +
sizeof(uint32_t) + mdxs - 1) /
DBLOCK_SIZE ==
460 serialized = (
char *) &e[1];
463 sptr = &serialized[slen +
sizeof(uint32_t)];
475 e->
len = slen +
sizeof(uint32_t) + mds;
488do_align (
size_t start_position,
size_t end_position)
493 if ((start_position < align) && (end_position > align))
494 return align + end_position - start_position;
523 for (i = 0; i < count; i++)
526 badness = 0x7FFFFFFF;
528 for (j = i; j < count; j++)
531 cend = cpos + sizes[cval];
559 perm[i] = perm[best];
561 cpos += sizes[perm[i]];
610 for (i = 0; i < bld->
count; i++)
619 for (i = 0; i < bld->
count; i++)
622 size += sizes[perm[i]];
645 sptr = &
data[off +
sizeof(uint32_t)];
649 size - off -
sizeof(uint32_t),
656 off +=
sizeof(uint32_t) +
ret;
657 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 start
Set if we are to start default services (including 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 uint32_t type
Type string converted to DNS type 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_FS_MetaData * meta
Meta-data provided via command-line option.
API for file sharing via GNUnet.
#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
void GNUNET_FS_meta_data_make_directory(struct GNUNET_FS_MetaData *md)
Set the MIMETYPE information for the given metadata to "application/gnunet-directory".
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.
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
#define GNUNET_FS_DIRECTORY_MIME
void(* GNUNET_FS_DirectoryEntryProcessor)(void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *meta, size_t length, const void *data)
Function used to process entries in a directory.
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?
struct GNUNET_FS_DirectoryBuilder * GNUNET_FS_directory_builder_create(const struct GNUNET_FS_MetaData *mdir)
Create a directory builder.
int GNUNET_FS_meta_data_test_for_directory(const struct GNUNET_FS_MetaData *md)
Does the meta-data claim that this is a directory? Checks if the mime-type is that of a GNUnet direct...
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_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a 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_directory_builder_add(struct GNUNET_FS_DirectoryBuilder *bld, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_MetaData *md, const void *data)
Add an entry to a directory.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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_FS_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.