aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-08-28 09:05:15 +0000
committerChristian Grothoff <christian@grothoff.org>2009-08-28 09:05:15 +0000
commit3b7b7b388b7968c11556ba92060a17a964c46451 (patch)
treebd37d3a7deb01c3c3a05326f7893f81732afc8f9 /src
parent57df0fbf8398720fbd4a9cf34934c212ea00ee54 (diff)
downloadgnunet-3b7b7b388b7968c11556ba92060a17a964c46451.tar.gz
gnunet-3b7b7b388b7968c11556ba92060a17a964c46451.zip
stuff
Diffstat (limited to 'src')
-rw-r--r--src/fs/Makefile.am13
-rw-r--r--src/fs/fs.h4
-rw-r--r--src/fs/fs_directory.c59
-rw-r--r--src/fs/fs_getopt.c4
-rw-r--r--src/fs/fs_publish.c111
-rw-r--r--src/fs/gnunet-publish.c556
-rw-r--r--src/include/gnunet_connection_lib.h6
-rw-r--r--src/include/gnunet_container_lib.h46
-rw-r--r--src/include/gnunet_fs_service.h8
-rw-r--r--src/include/gnunet_network_lib.h13
-rw-r--r--src/util/Makefile.am2
-rw-r--r--src/util/container_meta_data.c4
-rw-r--r--src/util/network_socket.c (renamed from src/util/sock.c)2
13 files changed, 752 insertions, 76 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 5aca42ac2..f1bc64784 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -26,6 +26,7 @@ libgnunetfs_la_SOURCES = \
26 fs_uri.c 26 fs_uri.c
27 27
28libgnunetfs_la_LIBADD = \ 28libgnunetfs_la_LIBADD = \
29 $(top_builddir)/src/datastore/libgnunetdatastore.la \
29 $(top_builddir)/src/util/libgnunetutil.la \ 30 $(top_builddir)/src/util/libgnunetutil.la \
30 -lextractor \ 31 -lextractor \
31 $(GN_LIBINTL) $(XLIB) 32 $(GN_LIBINTL) $(XLIB)
@@ -35,11 +36,11 @@ libgnunetfs_la_LDFLAGS = \
35 -version-info 0:0:0 36 -version-info 0:0:0
36 37
37 38
38#bin_PROGRAMS = 39bin_PROGRAMS = \
40 gnunet-publish
39# gnunet-directory 41# gnunet-directory
40# gnunet-download 42# gnunet-download
41# gnunet-pseudonym 43# gnunet-pseudonym
42# gnunet-publish
43# gnunet-search 44# gnunet-search
44# gnunet-unindex 45# gnunet-unindex
45 46
@@ -51,6 +52,14 @@ libgnunetfs_la_LDFLAGS = \
51# $(GN_LIBINTL) 52# $(GN_LIBINTL)
52 53
53 54
55gnunet_publish_SOURCES = \
56 gnunet-publish.c
57gnunet_publish_LDADD = \
58 $(top_builddir)/src/fs/libgnunetfs.la \
59 $(top_builddir)/src/util/libgnunetutil.la \
60 $(GN_LIBINTL)
61
62
54check_PROGRAMS = \ 63check_PROGRAMS = \
55 test_fs_collection \ 64 test_fs_collection \
56 test_fs_directory \ 65 test_fs_directory \
diff --git a/src/fs/fs.h b/src/fs/fs.h
index c66249613..3c92b42ae 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -308,13 +308,13 @@ struct GNUNET_FS_FileInformation
308 * Size of the directory itself (in bytes); 0 if the 308 * Size of the directory itself (in bytes); 0 if the
309 * size has not yet been calculated. 309 * size has not yet been calculated.
310 */ 310 */
311 uint64_t dir_size; 311 size_t dir_size;
312 312
313 /** 313 /**
314 * Pointer to the data for the directory (or NULL if not 314 * Pointer to the data for the directory (or NULL if not
315 * available). 315 * available).
316 */ 316 */
317 char *dir_data; 317 void *dir_data;
318 318
319 } dir; 319 } dir;
320 320
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c
index e5a9f963f..489cf8f19 100644
--- a/src/fs/fs_directory.c
+++ b/src/fs/fs_directory.c
@@ -24,7 +24,6 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * 25 *
26 * TODO: 26 * TODO:
27 * - add support for embedded file data (use padding room!)
28 * - modify directory builder API to support incremental 27 * - modify directory builder API to support incremental
29 * generation of directories (to allow directories that 28 * generation of directories (to allow directories that
30 * would not fit into memory to be created) 29 * would not fit into memory to be created)
@@ -42,6 +41,13 @@
42#endif 41#endif
43 42
44/** 43/**
44 * String that is used to indicate that a file
45 * is a GNUnet directory.
46 */
47#define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n"
48
49
50/**
45 * Does the meta-data claim that this is a directory? 51 * Does the meta-data claim that this is a directory?
46 * Checks if the mime-type is that of a GNUnet directory. 52 * Checks if the mime-type is that of a GNUnet directory.
47 * 53 *
@@ -118,6 +124,7 @@ GNUNET_FS_directory_list_contents (size_t size,
118 void *dep_cls) 124 void *dep_cls)
119{ 125{
120 const char *cdata = data; 126 const char *cdata = data;
127 char *file_data;
121 char *emsg; 128 char *emsg;
122 uint64_t pos; 129 uint64_t pos;
123 uint64_t align; 130 uint64_t align;
@@ -217,17 +224,18 @@ GNUNET_FS_directory_list_contents (size_t size,
217 return; /* malformed ! */ 224 return; /* malformed ! */
218 } 225 }
219 pos += mdSize; 226 pos += mdSize;
220 // EXTRACTOR_GNUNET_FULL_DATA
221 /* FIXME: add support for embedded data */
222 filename = GNUNET_CONTAINER_meta_data_get_by_type (md, 227 filename = GNUNET_CONTAINER_meta_data_get_by_type (md,
223 EXTRACTOR_FILENAME); 228 EXTRACTOR_FILENAME);
229 file_data = GNUNET_CONTAINER_meta_data_get_by_type (md,
230 EXTRACTOR_GNUNET_FULL_DATA);
224 if (dep != NULL) 231 if (dep != NULL)
225 dep (dep_cls, 232 dep (dep_cls,
226 filename, 233 filename,
227 uri, 234 uri,
228 md, 235 md,
229 0, 236 (file_data != NULL) ? strlen(file_data) : 0,
230 NULL); 237 file_data);
238 GNUNET_free_non_null (file_data);
231 GNUNET_free_non_null (filename); 239 GNUNET_free_non_null (filename);
232 GNUNET_CONTAINER_meta_data_destroy (md); 240 GNUNET_CONTAINER_meta_data_destroy (md);
233 GNUNET_FS_uri_destroy (uri); 241 GNUNET_FS_uri_destroy (uri);
@@ -308,6 +316,7 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
308 struct BuilderEntry *e; 316 struct BuilderEntry *e;
309 uint64_t fsize; 317 uint64_t fsize;
310 uint32_t big; 318 uint32_t big;
319 ssize_t ret;
311 size_t mds; 320 size_t mds;
312 size_t mdxs; 321 size_t mdxs;
313 char *uris; 322 char *uris;
@@ -316,12 +325,12 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
316 struct GNUNET_CONTAINER_MetaData *meta; 325 struct GNUNET_CONTAINER_MetaData *meta;
317 const struct GNUNET_CONTAINER_MetaData *meta_use; 326 const struct GNUNET_CONTAINER_MetaData *meta_use;
318 327
319 GNUNET_assert (! GNUNET_FS_uri_ksk_test (uri)); 328 GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri));
320 if (NULL != data) 329 if (NULL != data)
321 if (GNUNET_FS_uri_chk_test (uri)) 330 if (GNUNET_FS_uri_test_chk (uri))
322 fsize = GNUNET_FS_uri_chk_get_size (uri); 331 fsize = GNUNET_FS_uri_chk_get_file_size (uri);
323 else 332 else
324 fsize = GNUNET_FS_uri_chk_get_size (GNUNET_FS_uri_loc_get_uri (uri)); 333 fsize = GNUNET_FS_uri_chk_get_file_size (GNUNET_FS_uri_loc_get_uri (uri));
325 else 334 else
326 fsize = 0; /* not given */ 335 fsize = 0; /* not given */
327 if (fsize > GNUNET_FS_MAX_INLINE_SIZE) 336 if (fsize > GNUNET_FS_MAX_INLINE_SIZE)
@@ -500,8 +509,8 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
500 uint32_t big; 509 uint32_t big;
501 510
502 size = 8 + sizeof (uint32_t); 511 size = 8 + sizeof (uint32_t);
503 size += GNUNET_meta_data_get_serialized_size (bld->meta, 512 size += GNUNET_CONTAINER_meta_data_get_serialized_size (bld->meta,
504 GNUNET_SERIALIZE_FULL); 513 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
505 if (bld->count > 0) 514 if (bld->count > 0)
506 { 515 {
507 sizes = GNUNET_malloc (bld->count * sizeof (size_t)); 516 sizes = GNUNET_malloc (bld->count * sizeof (size_t));
@@ -512,7 +521,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
512 { 521 {
513 perm[i] = i; 522 perm[i] = i;
514 bes[i] = pos; 523 bes[i] = pos;
515 sizes[i] = pos->size; 524 sizes[i] = pos->len;
516 pos = pos->next; 525 pos = pos->next;
517 } 526 }
518 } 527 }
@@ -534,22 +543,22 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
534 memcpy (data, GNUNET_DIRECTORY_MAGIC, 8); 543 memcpy (data, GNUNET_DIRECTORY_MAGIC, 8);
535 off = 8; 544 off = 8;
536 545
537 ret = GNUNET_CONTAINER_meta_data_serialize (meta, 546 ret = GNUNET_CONTAINER_meta_data_serialize (bld->meta,
538 &(*data)[off + 547 &data[off +
539 sizeof (uint32_t)], 548 sizeof (uint32_t)],
540 size - pos - sizeof (uint32_t), 549 size - off - sizeof (uint32_t),
541 GNUNET_SERIALIZE_FULL); 550 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
542 GNUNET_assert (ret != -1); 551 GNUNET_assert (ret != -1);
543 big = htonl (ret); 552 big = htonl (ret);
544 memcpy (&(*data)[8], &big, sizeof (uint32_t)); 553 memcpy (&data[8], &big, sizeof (uint32_t));
545 pos += sizeof (uint32_t) + ret; 554 off += sizeof (uint32_t) + ret;
546 for (j = 0; j < count; j++) 555 for (j = 0; j < bld->count; j++)
547 { 556 {
548 i = perm[j]; 557 i = perm[j];
549 psize = pos; 558 psize = off;
550 pos += sizes[i]; 559 off += sizes[i];
551 pos = do_align (psize, pos); 560 off = do_align (psize, off);
552 memcpy (&data[pos - sizes[i]], 561 memcpy (&data[off - sizes[i]],
553 &(bes[i])[1], 562 &(bes[i])[1],
554 sizes[i]); 563 sizes[i]);
555 GNUNET_free (bes[i]); 564 GNUNET_free (bes[i]);
@@ -557,7 +566,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
557 GNUNET_free (sizes); 566 GNUNET_free (sizes);
558 GNUNET_free (perm); 567 GNUNET_free (perm);
559 GNUNET_free (bes); 568 GNUNET_free (bes);
560 GNUNET_assert (pos == size); 569 GNUNET_assert (off == size);
561 GNUNET_CONTAINER_meta_data_destroy (bld->meta); 570 GNUNET_CONTAINER_meta_data_destroy (bld->meta);
562 GNUNET_free (bld); 571 GNUNET_free (bld);
563} 572}
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index dfcc4fdc4..a0d232641 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -42,7 +42,7 @@
42 * @return GNUNET_OK on success 42 * @return GNUNET_OK on success
43 */ 43 */
44int 44int
45GNUNET_FS_getopt_configure_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx, 45GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
46 void *scls, 46 void *scls,
47 const char *option, 47 const char *option,
48 const char *value) 48 const char *value)
@@ -124,7 +124,7 @@ GNUNET_FS_getopt_configure_set_keywords (struct GNUNET_GETOPT_CommandLineProcess
124 * @return GNUNET_OK on success 124 * @return GNUNET_OK on success
125 */ 125 */
126int 126int
127GNUNET_FS_getopt_configure_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx, 127GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
128 void *scls, 128 void *scls,
129 const char *option, 129 const char *option,
130 const char *value) 130 const char *value)
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 0078d0d32..f5c2b4cdc 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -26,7 +26,6 @@
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 * 27 *
28 * TODO: 28 * TODO:
29 * - directory creation
30 * - KBlocks 29 * - KBlocks
31 * - SBlocks 30 * - SBlocks
32 * - indexing support 31 * - indexing support
@@ -119,6 +118,7 @@ ds_put_cont (void *cls,
119 * 118 *
120 * @param sc overall upload data 119 * @param sc overall upload data
121 * @param p file that the block belongs to (needed for options!) 120 * @param p file that the block belongs to (needed for options!)
121 * @param query what the block should be indexed under
122 * @param blk encoded block to publish 122 * @param blk encoded block to publish
123 * @param blk_size size of the block 123 * @param blk_size size of the block
124 * @param blk_type type of the block 124 * @param blk_type type of the block
@@ -127,15 +127,14 @@ ds_put_cont (void *cls,
127static void 127static void
128publish_block (struct GNUNET_FS_PublishContext *sc, 128publish_block (struct GNUNET_FS_PublishContext *sc,
129 struct GNUNET_FS_FileInformation *p, 129 struct GNUNET_FS_FileInformation *p,
130 const GNUNET_HashCode *query,
130 const void* blk, 131 const void* blk,
131 uint16_t blk_size, 132 uint16_t blk_size,
132 uint32_t blk_type, 133 uint32_t blk_type,
133 GNUNET_SCHEDULER_Task cont) 134 GNUNET_SCHEDULER_Task cont)
134{ 135{
135 struct GNUNET_HashCode key; 136 struct PutContCtx * dpc_cls;
136 137
137 // FIXME: GNUNET_FS_get_key (blk_type, blk, blk_size, &key);
138 // (or add "key" as argument to reduce hashing?)
139 dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx)); 138 dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx));
140 dpc_cls->cont = cont; 139 dpc_cls->cont = cont;
141 dpc_cls->sc = sc; 140 dpc_cls->sc = sc;
@@ -146,8 +145,9 @@ publish_block (struct GNUNET_FS_PublishContext *sc,
146 // a task ID! 145 // a task ID!
147 GNUNET_DATASTORE_put (sc->dsh, 146 GNUNET_DATASTORE_put (sc->dsh,
148 sc->rid, 147 sc->rid,
149 &key, 148 query,
150 blk_size, 149 blk_size,
150 blk,
151 blk_type, 151 blk_type,
152 p->priority, 152 p->priority,
153 p->anonymity, 153 p->anonymity,
@@ -280,7 +280,8 @@ compute_chk_offset (unsigned int height,
280 uint64_t offset) 280 uint64_t offset)
281{ 281{
282 uint64_t bds; 282 uint64_t bds;
283 unsigned int ret; 283 unsigned int ret;
284 unsigned int i;
284 285
285 bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i" 286 bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i"
286 corresponds to */ 287 corresponds to */
@@ -305,7 +306,7 @@ static void
305publish_content (struct GNUNET_FS_PublishContext *sc, 306publish_content (struct GNUNET_FS_PublishContext *sc,
306 struct GNUNET_FS_FileInformation *p) 307 struct GNUNET_FS_FileInformation *p)
307{ 308{
308 struct ContentHashKey *chk; 309 struct ContentHashKey *mychk;
309 const void *pt_block; 310 const void *pt_block;
310 uint16_t pt_size; 311 uint16_t pt_size;
311 char *emsg; 312 char *emsg;
@@ -315,6 +316,10 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
315 struct GNUNET_CRYPTO_AesInitializationVector iv; 316 struct GNUNET_CRYPTO_AesInitializationVector iv;
316 uint64_t size; 317 uint64_t size;
317 unsigned int off; 318 unsigned int off;
319 struct GNUNET_FS_DirectoryBuilder *db;
320 struct GNUNET_FS_FileInformation *dirpos;
321 void *raw_data;
322 char *dd;
318 323
319 // FIXME: figure out how to share this code 324 // FIXME: figure out how to share this code
320 // with unindex! 325 // with unindex!
@@ -323,14 +328,47 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
323 { 328 {
324 if (p->is_directory) 329 if (p->is_directory)
325 { 330 {
326 /* FIXME: create function to create directory 331 db = GNUNET_FS_directory_builder_create (p->meta);
327 and use that API here! */ 332 dirpos = p->data.dir.entries;
328 GNUNET_FS_directory_create (&p->data.dir.dir_size, 333 while (NULL != dirpos)
329 &p->data.dir.dir_data, 334 {
330 p->meta, 335 if (dirpos->is_directory)
331 &directory_entry_lister, 336 {
332 p->data.dir.entries); 337 raw_data = dirpos->data.dir.dir_data;
333 size = p->data.dir.data_size; 338 dirpos->data.dir.dir_data = NULL;
339 }
340 else
341 {
342 raw_data = NULL;
343 if ( (dirpos->data.file.file_size < GNUNET_FS_MAX_INLINE_SIZE) &&
344 (dirpos->data.file.file_size > 0) )
345 {
346 raw_data = GNUNET_malloc (dirpos->data.file.file_size);
347 emsg = NULL;
348 if (dirpos->data.file.file_size !=
349 dirpos->data.file.reader (dirpos->data.file.reader_cls,
350 0,
351 dirpos->data.file.file_size,
352 raw_data,
353 &emsg))
354 {
355 GNUNET_free_non_null (emsg);
356 GNUNET_free (raw_data);
357 raw_data = NULL;
358 }
359 }
360 }
361 GNUNET_FS_directory_builder_add (db,
362 dirpos->chk_uri,
363 dirpos->meta,
364 raw_data);
365 GNUNET_free_non_null (raw_data);
366 dirpos = dirpos->next;
367 }
368 GNUNET_FS_directory_builder_finish (db,
369 &p->data.dir.dir_size,
370 &p->data.dir.dir_data);
371 size = p->data.dir.dir_size;
334 } 372 }
335 p->chk_tree_depth = compute_depth (size); 373 p->chk_tree_depth = compute_depth (size);
336 p->chk_tree = GNUNET_malloc (p->chk_tree_depth * 374 p->chk_tree = GNUNET_malloc (p->chk_tree_depth *
@@ -344,17 +382,24 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
344 { 382 {
345 pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE, 383 pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE,
346 p->data.dir.dir_size - p->publish_offset); 384 p->data.dir.dir_size - p->publish_offset);
347 pt_block = &p->data.dir.dir_data[p->publish_offset]; 385 dd = p->data.dir.dir_data;
386 pt_block = &dd[p->publish_offset];
348 } 387 }
349 else 388 else
350 { 389 {
351 pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE, 390 pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE,
352 p->data.file.file_size - p->publish_offset); 391 p->data.file.file_size - p->publish_offset);
353 p->data.file.reader (p->data.file.reader_cls, 392 emsg = NULL;
354 p->publish_offset, 393 if (pt_size !=
355 pt_size, 394 p->data.file.reader (p->data.file.reader_cls,
356 iob, 395 p->publish_offset,
357 &emsg); 396 pt_size,
397 iob,
398 &emsg))
399 {
400 // FIXME: abort with error "emsg"
401 GNUNET_free (emsg);
402 }
358 pt_block = iob; 403 pt_block = iob;
359 } 404 }
360 } 405 }
@@ -367,9 +412,9 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
367 } 412 }
368 off = compute_chk_offset (p->chk_tree_depth - p->current_depth, 413 off = compute_chk_offset (p->chk_tree_depth - p->current_depth,
369 p->publish_offset); 414 p->publish_offset);
370 chk = &p->chk_tree[(p->current_depth-1)*GNUNET_FS_CHK_PER_INODE+off]; 415 mychk = &p->chk_tree[(p->current_depth-1)*GNUNET_FS_CHK_PER_INODE+off];
371 GNUNET_CRYPTO_hash (pt_block, pt_size, &chk->key); 416 GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key);
372 GNUNET_CRYPTO_hash_to_aes_key (&chk->key, &sk, &iv); 417 GNUNET_CRYPTO_hash_to_aes_key (&mychk->key, &sk, &iv);
373 GNUNET_CRYPTO_aes_encrypt (pt_block, 418 GNUNET_CRYPTO_aes_encrypt (pt_block,
374 pt_size, 419 pt_size,
375 &sk, 420 &sk,
@@ -379,13 +424,16 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
379 // between publish/unindex! Parameterize & move this code! 424 // between publish/unindex! Parameterize & move this code!
380 // FIXME: something around here would need to change 425 // FIXME: something around here would need to change
381 // for indexing! 426 // for indexing!
382 publish_block (sc, p, enc, pt_size, 427 publish_block (sc, p,
428 &mychk->query,
429 enc,
430 pt_size,
383 (p->current_depth == p->chk_tree_depth) 431 (p->current_depth == p->chk_tree_depth)
384 ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK 432 ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK
385 : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK, 433 : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK,
386 &do_upload); 434 &do_upload);
387 // FIXME: should call progress function somewhere here! 435 // FIXME: should call progress function somewhere here!
388 GNUNET_CRYPTO_hash (enc, pt_size, &chk->query); 436 GNUNET_CRYPTO_hash (enc, pt_size, &mychk->query);
389 if (p->current_depth == p->chk_tree_depth) 437 if (p->current_depth == p->chk_tree_depth)
390 { 438 {
391 p->publish_offset += pt_size; 439 p->publish_offset += pt_size;
@@ -404,9 +452,9 @@ publish_content (struct GNUNET_FS_PublishContext *sc,
404 if (0 == p->current_depth) 452 if (0 == p->current_depth)
405 { 453 {
406 p->chk_uri = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri)); 454 p->chk_uri = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri));
407 p->chk_uri.type = chk; 455 p->chk_uri->type = chk;
408 p->chk_uri.data.chk.chk = p->chk_tree[0]; 456 p->chk_uri->data.chk.chk = p->chk_tree[0];
409 p->chk_uri.data.chk.file_length = size; 457 p->chk_uri->data.chk.file_length = size;
410 GNUNET_free (p->chk_tree); 458 GNUNET_free (p->chk_tree);
411 p->chk_tree = NULL; 459 p->chk_tree = NULL;
412 } 460 }
@@ -445,7 +493,8 @@ do_upload (void *cls,
445 publish_kblocks (sc, p); 493 publish_kblocks (sc, p);
446 return; 494 return;
447 } 495 }
448 if (p->do_index) 496 if ( (!p->is_directory) &&
497 (p->data.file.do_index) )
449 { 498 {
450 // FIXME: need to pre-compute hash over 499 // FIXME: need to pre-compute hash over
451 // the entire file and ask FS to prepare 500 // the entire file and ask FS to prepare
@@ -542,7 +591,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *sc)
542 GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO); 591 GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO);
543 GNUNET_free_non_null (sc->nid); 592 GNUNET_free_non_null (sc->nid);
544 GNUNET_free_non_null (sc->nuid); 593 GNUNET_free_non_null (sc->nuid);
545 GNUNET_DATASTORE_disconnect (sc->dsh); 594 GNUNET_DATASTORE_disconnect (sc->dsh, GNUNET_NO);
546 GNUNET_free (sc); 595 GNUNET_free (sc);
547} 596}
548 597
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
new file mode 100644
index 000000000..58885c234
--- /dev/null
+++ b/src/fs/gnunet-publish.c
@@ -0,0 +1,556 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file fs/gnunet-publish.c
22 * @brief publishing files on GNUnet
23 * @author Christian Grothoff
24 * @author Krista Bennett
25 * @author James Blackwell
26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - support for some options is still missing (uri argument, simulate)
30 * - progress callbacks not implemented (and need verbosity option)
31 * - clean shutdown is not implemented (stop ctx, etc.)
32 */
33#include "platform.h"
34#include "gnunet_fs_service.h"
35
36#define DEFAULT_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 2)
37
38static int ret;
39
40static const struct GNUNET_CONFIGURATION_Handle *cfg;
41
42static struct GNUNET_FS_Handle *ctx;
43
44static struct GNUNET_FS_PublishContext *pc;
45
46static struct GNUNET_TIME_Absolute start_time;
47
48static struct GNUNET_CONTAINER_MetaData *meta;
49
50static struct GNUNET_FS_Uri *topKeywords;
51
52static unsigned int anonymity = 1;
53
54static unsigned int priority = 365;
55
56static char *uri_string;
57
58static char *next_id;
59
60static char *this_id;
61
62static char *pseudonym;
63
64static int do_insert;
65
66static int disable_extractor;
67
68static int do_simulate;
69
70static int extract_only;
71
72static int do_disable_creation_time;
73
74
75/**
76 * Called by FS client to give information about the progress of an
77 * operation.
78 *
79 * @param cls closure
80 * @param info details about the event, specifying the event type
81 * and various bits about the event
82 * @return client-context (for the next progress call
83 * for this operation; should be set to NULL for
84 * SUSPEND and STOPPED events). The value returned
85 * will be passed to future callbacks in the respective
86 * field in the GNUNET_FS_ProgressInfo struct.
87 */
88static void *
89progress_cb (void *cls,
90 const struct GNUNET_FS_ProgressInfo *info)
91{
92 return NULL;
93}
94
95
96/**
97 * Print metadata entries (except binary
98 * metadata and the filename).
99 *
100 * @param cls closure
101 * @param type type of the meta data
102 * @param data value of the meta data
103 * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
104 */
105static int
106meta_printer (void *cls,
107 EXTRACTOR_KeywordType type,
108 const char *data)
109{
110 if ( (type == EXTRACTOR_FILENAME) ||
111 (EXTRACTOR_isBinaryType (type)) )
112 return GNUNET_OK;
113 fprintf (stdout,
114 "%s - %s",
115 EXTRACTOR_getKeywordTypeAsString (type),
116 data);
117 return GNUNET_OK;
118}
119
120
121/**
122 * Merge metadata entries (except binary
123 * metadata).
124 *
125 * @param cls closure, target metadata structure
126 * @param type type of the meta data
127 * @param data value of the meta data
128 * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
129 */
130static int
131meta_merger (void *cls,
132 EXTRACTOR_KeywordType type,
133 const char *data)
134{
135 struct GNUNET_CONTAINER_MetaData *m = cls;
136 GNUNET_CONTAINER_meta_data_insert (m,
137 type,
138 data);
139 return GNUNET_OK;
140}
141
142
143/**
144 * Function called on all entries before the
145 * publication. This is where we perform
146 * modifications to the default based on
147 * command-line options.
148 *
149 * @param cls closure
150 * @param fi the entry in the publish-structure
151 * @param length length of the file or directory
152 * @param m metadata for the file or directory (can be modified)
153 * @param uri pointer to the keywords that will be used for this entry (can be modified)
154 * @param anonymity pointer to selected anonymity level (can be modified)
155 * @param priority pointer to selected priority (can be modified)
156 * @param expirationTime pointer to selected expiration time (can be modified)
157 * @param client_info pointer to client context set upon creation (can be modified)
158 * @return GNUNET_OK to continue, GNUNET_NO to remove
159 * this entry from the directory, GNUNET_SYSERR
160 * to abort the iteration
161 */
162static int
163publish_inspector (void *cls,
164 struct GNUNET_FS_FileInformation *fi,
165 uint64_t length,
166 struct GNUNET_CONTAINER_MetaData *m,
167 struct GNUNET_FS_Uri **uri,
168 unsigned int *anonymity,
169 unsigned int *priority,
170 struct GNUNET_TIME_Absolute *expirationTime,
171 void **client_info)
172{
173 char *fn;
174 char *fs;
175 struct GNUNET_FS_Uri *new_uri;
176
177 if (! do_disable_creation_time)
178 GNUNET_CONTAINER_meta_data_add_publication_date (meta);
179 if (NULL != topKeywords)
180 {
181 new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
182 *uri);
183 GNUNET_FS_uri_destroy (*uri);
184 *uri = new_uri;
185 GNUNET_FS_uri_destroy (topKeywords);
186 topKeywords = NULL;
187 }
188 if (NULL != meta)
189 {
190 GNUNET_CONTAINER_meta_data_get_contents (meta,
191 &meta_merger,
192 m);
193 GNUNET_CONTAINER_meta_data_destroy (meta);
194 meta = NULL;
195 }
196 if (extract_only)
197 {
198 fn = GNUNET_CONTAINER_meta_data_get_by_type (meta,
199 EXTRACTOR_FILENAME);
200 fs = GNUNET_STRINGS_byte_size_fancy (length);
201 fprintf (stdout,
202 _("Keywords for file `%s' (%s)\n"),
203 fn,
204 fs);
205 GNUNET_free (fn);
206 GNUNET_free (fs);
207 GNUNET_CONTAINER_meta_data_get_contents (meta,
208 &meta_printer,
209 NULL);
210 fprintf (stdout, "\n");
211 }
212 if (GNUNET_FS_meta_data_test_for_directory (meta))
213 GNUNET_FS_file_information_inspect (fi,
214 &publish_inspector,
215 NULL);
216 return GNUNET_OK;
217}
218
219
220/**
221 * Main function that will be run by the scheduler.
222 *
223 * @param cls closure
224 * @param sched the scheduler to use
225 * @param args remaining command-line arguments
226 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
227 * @param cfg configuration
228 */
229static void
230run (void *cls,
231 struct GNUNET_SCHEDULER_Handle *sched,
232 char *const *args,
233 const char *cfgfile,
234 const struct GNUNET_CONFIGURATION_Handle *c)
235{
236 struct GNUNET_FS_FileInformation *fi;
237 struct GNUNET_FS_Namespace *namespace;
238 EXTRACTOR_ExtractorList *l;
239 char *ex;
240 char *emsg;
241
242 /* check arguments */
243 if ( ( (uri_string == NULL) || (extract_only) )
244 && ( (args[0] == NULL) || (args[1] != NULL) ) )
245 {
246 printf (_
247 ("You must specify one and only one filename for insertion.\n"));
248 ret = -1;
249 return;
250 }
251 if ((uri_string != NULL) && (args[0] != NULL))
252 {
253 printf (_("You must NOT specify an URI and a filename.\n"));
254 ret = -1;
255 return;
256 }
257 if ((uri_string != NULL) && (extract_only))
258 {
259 printf (_("Cannot extract metadata from a URI!\n"));
260 ret = -1;
261 return;
262 }
263 if (pseudonym != NULL)
264 {
265 if (NULL == this_id)
266 {
267 fprintf (stderr,
268 _("Option `%s' is required when using option `%s'.\n"),
269 "-t", "-P");
270 ret = -1;
271 return;
272 }
273 }
274 else
275 { /* ordinary insertion checks */
276 if (NULL != next_id)
277 {
278 fprintf (stderr,
279 _("Option `%s' makes no sense without option `%s'.\n"),
280 "-N", "-P");
281 ret = -1;
282 return;
283 }
284 if (NULL != this_id)
285 {
286 fprintf (stderr,
287 _("Option `%s' makes no sense without option `%s'.\n"),
288 "-t", "-P");
289 ret = -1;
290 return;
291 }
292 }
293 if (args[0] == NULL)
294 {
295 fprintf (stderr,
296 _("Need the name of a file to publish!\n"));
297 ret = 1;
298 return;
299 }
300 cfg = c;
301 ctx = GNUNET_FS_start (sched,
302 cfg,
303 "gnunet-publish",
304 &progress_cb,
305 NULL);
306 if (NULL == ctx)
307 {
308 fprintf (stderr,
309 _("Could not initialize `%s' subsystem.\n"),
310 "FS");
311 ret = 1;
312 return;
313 }
314 namespace = NULL;
315 if (NULL != pseudonym)
316 {
317 namespace = GNUNET_FS_namespace_create (ctx,
318 pseudonym);
319 if (NULL == namespace)
320 {
321 fprintf (stderr,
322 _("Could not create namespace `%s'\n"),
323 pseudonym);
324 GNUNET_FS_stop (ctx);
325 ret = 1;
326 return;
327 }
328 }
329 if (NULL != uri_string)
330 {
331 // FIXME -- implement!
332 return;
333 }
334 start_time = GNUNET_TIME_absolute_get ();
335
336 l = NULL;
337 if (! disable_extractor)
338 {
339 l = EXTRACTOR_loadDefaultLibraries ();
340 if (GNUNET_OK ==
341 GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS",
342 &ex))
343 {
344 if (strlen (ex) > 0)
345 l = EXTRACTOR_loadConfigLibraries (l, ex);
346 GNUNET_free (ex);
347 }
348 }
349 fi = GNUNET_FS_file_information_create_from_directory (NULL,
350 args[0],
351 &GNUNET_FS_directory_scanner_default,
352 l,
353 !do_insert,
354 anonymity,
355 priority,
356 GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
357 &emsg);
358 EXTRACTOR_removeAll (l);
359 if (fi == NULL)
360 {
361 fprintf (stderr,
362 _("Could not publish `%s': %s\n"),
363 args[0],
364 emsg);
365 GNUNET_free (emsg);
366 if (namespace != NULL)
367 GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
368 GNUNET_FS_stop (ctx);
369 ret = 1;
370 return;
371 }
372 GNUNET_FS_file_information_inspect (fi,
373 &publish_inspector,
374 NULL);
375 if (extract_only)
376 {
377 if (namespace != NULL)
378 GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
379 GNUNET_FS_file_information_destroy (fi, NULL, NULL);
380 GNUNET_FS_stop (ctx);
381 return;
382 }
383 pc = GNUNET_FS_publish_start (ctx,
384 NULL,
385 fi,
386 namespace,
387 this_id,
388 next_id);
389}
390
391
392/**
393 * gnunet-publish command line options
394 */
395static struct GNUNET_GETOPT_CommandLineOption options[] = {
396 {'a', "anonymity", "LEVEL",
397 gettext_noop ("set the desired LEVEL of sender-anonymity"),
398 1, &GNUNET_GETOPT_set_uint, &anonymity},
399 {'d', "disable-creation-time", NULL,
400 gettext_noop
401 ("disable adding the creation time to the metadata of the uploaded file"),
402 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
403 {'D', "disable-extractor", NULL,
404 gettext_noop
405 ("do not use libextractor to add keywords or metadata"),
406 0, &GNUNET_GETOPT_set_one, &disable_extractor},
407 {'e', "extract", NULL,
408 gettext_noop
409 ("print list of extracted keywords that would be used, but do not perform upload"),
410 0, &GNUNET_GETOPT_set_one, &extract_only},
411 {'k', "key", "KEYWORD",
412 gettext_noop
413 ("add an additional keyword for the top-level file or directory"
414 " (this option can be specified multiple times)"),
415 1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
416 // *: option not yet used... (can handle in a pass over FI)
417 {'m', "meta", "TYPE:VALUE",
418 gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
419 1, &GNUNET_FS_getopt_set_metadata, &meta},
420 {'n', "noindex", NULL,
421 gettext_noop ("do not index, perform full insertion (stores entire "
422 "file in encrypted form in GNUnet database)"),
423 0, &GNUNET_GETOPT_set_one, &do_insert},
424 {'N', "next", "ID",
425 gettext_noop
426 ("specify ID of an updated version to be published in the future"
427 " (for namespace insertions only)"),
428 1, &GNUNET_GETOPT_set_string, &next_id},
429 {'p', "priority", "PRIORITY",
430 gettext_noop ("specify the priority of the content"),
431 1, &GNUNET_GETOPT_set_uint, &priority},
432 {'P', "pseudonym", "NAME",
433 gettext_noop
434 ("publish the files under the pseudonym NAME (place file into namespace)"),
435 1, &GNUNET_GETOPT_set_string, &pseudonym},
436 // *: option not yet used... (need FS API support!)
437 {'s', "simulate-only", NULL,
438 gettext_noop ("only simulate the process but do not do any "
439 "actual publishing (useful to compute URIs)"),
440 0, &GNUNET_GETOPT_set_one, &do_simulate},
441 {'t', "this", "ID",
442 gettext_noop ("set the ID of this version of the publication"
443 " (for namespace insertions only)"),
444 1, &GNUNET_GETOPT_set_string, &this_id},
445 // *: option not yet used... (need FS API support!)
446 {'u', "uri", "URI",
447 gettext_noop ("URI to be published (can be used instead of passing a "
448 "file to add keywords to the file with the respective URI)"),
449 1, &GNUNET_GETOPT_set_string, &uri_string},
450 GNUNET_GETOPT_OPTION_END
451};
452
453
454/**
455 * The main function to publish content to GNUnet.
456 *
457 * @param argc number of arguments from the command line
458 * @param argv command line arguments
459 * @return 0 ok, 1 on error
460 */
461int
462main (int argc, char *const *argv)
463{
464 return (GNUNET_OK ==
465 GNUNET_PROGRAM_run (argc,
466 argv,
467 "gnunet-publish",
468 gettext_noop
469 ("Publish files on GNUnet."),
470 options, &run, NULL)) ? ret : 1;
471}
472
473/* end of gnunet-publish.c */
474
475////////////////////////////////////////////////////////////////
476
477
478/**
479 * Print progess message.
480 */
481static void *
482printstatus (void *ctx, const GNUNET_FSUI_Event * event)
483{
484 unsigned long long delta;
485 char *fstring;
486
487 switch (event->type)
488 {
489 case GNUNET_FSUI_upload_progress:
490 if (*verboselevel)
491 {
492 char *ret;
493 GNUNET_CronTime now;
494
495 now = GNUNET_get_time ();
496 delta = event->data.UploadProgress.eta - now;
497 if (event->data.UploadProgress.eta < now)
498 delta = 0;
499 ret = GNUNET_get_time_interval_as_fancy_string (delta);
500 PRINTF (_("%16llu of %16llu bytes inserted "
501 "(estimating %6s to completion) - %s\n"),
502 event->data.UploadProgress.completed,
503 event->data.UploadProgress.total,
504 ret, event->data.UploadProgress.filename);
505 GNUNET_free (ret);
506 }
507 break;
508 case GNUNET_FSUI_upload_completed:
509 if (*verboselevel)
510 {
511 delta = GNUNET_get_time () - start_time;
512 PRINTF (_("Upload of `%s' complete, "
513 "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
514 event->data.UploadCompleted.filename,
515 event->data.UploadCompleted.total,
516 delta / GNUNET_CRON_SECONDS,
517 (delta == 0)
518 ? (double) (-1.0)
519 : (double) (event->data.UploadCompleted.total
520 / 1024.0 * GNUNET_CRON_SECONDS / delta));
521 }
522 fstring = GNUNET_ECRS_uri_to_string (event->data.UploadCompleted.uri);
523 printf (_("File `%s' has URI: %s\n"),
524 event->data.UploadCompleted.filename, fstring);
525 GNUNET_free (fstring);
526 if (ul == event->data.UploadCompleted.uc.pos)
527 {
528 postProcess (event->data.UploadCompleted.uri);
529 errorCode = 0;
530 GNUNET_shutdown_initiate ();
531 }
532 break;
533 case GNUNET_FSUI_upload_aborted:
534 printf (_("\nUpload aborted.\n"));
535 errorCode = 2;
536 GNUNET_shutdown_initiate ();
537 break;
538 case GNUNET_FSUI_upload_error:
539 printf (_("\nError uploading file: %s"),
540 event->data.UploadError.message);
541 errorCode = 3;
542 GNUNET_shutdown_initiate ();
543 break;
544 case GNUNET_FSUI_upload_started:
545 case GNUNET_FSUI_upload_stopped:
546 break;
547 default:
548 printf (_("\nUnexpected event: %d\n"), event->type);
549 GNUNET_GE_BREAK (ectx, 0);
550 break;
551 }
552 return NULL;
553}
554#endif
555
556/* end of gnunet-publish.c */
diff --git a/src/include/gnunet_connection_lib.h b/src/include/gnunet_connection_lib.h
index bc4aeea9b..69bd7d4a6 100644
--- a/src/include/gnunet_connection_lib.h
+++ b/src/include/gnunet_connection_lib.h
@@ -23,8 +23,8 @@
23 * @brief basic, low-level TCP networking interface 23 * @brief basic, low-level TCP networking interface
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#ifndef GNUNET_NETWORK_LIB_H 26#ifndef GNUNET_CONNECTION_LIB_H
27#define GNUNET_NETWORK_LIB_H 27#define GNUNET_CONNECTION_LIB_H
28 28
29#ifdef __cplusplus 29#ifdef __cplusplus
30extern "C" 30extern "C"
@@ -325,6 +325,6 @@ GNUNET_NETWORK_connection_notify_transmit_ready_cancel (struct
325#endif 325#endif
326 326
327 327
328/* ifndef GNUNET_NETWORK_LIB_H */ 328/* ifndef GNUNET_CONNECTION_LIB_H */
329#endif 329#endif
330/* end of gnunet_connection_lib.h */ 330/* end of gnunet_connection_lib.h */
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index e2a0787c8..1adae17b1 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Christian Grothoff (and other contributing authors) 3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -201,11 +201,16 @@ typedef int (*GNUNET_CONTAINER_MetaDataProcessor) (void *cls,
201 201
202/** 202/**
203 * Create a fresh MetaData token. 203 * Create a fresh MetaData token.
204 *
205 * @return empty meta-data container
204 */ 206 */
205struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void); 207struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void);
206 208
207/** 209/**
208 * Duplicate a MetaData token. 210 * Duplicate a MetaData token.
211 *
212 * @param meta what to duplicate
213 * @return duplicate meta-data container
209 */ 214 */
210struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const 215struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const
211 struct 216 struct
@@ -214,12 +219,18 @@ struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const
214 219
215/** 220/**
216 * Free meta data. 221 * Free meta data.
222 *
223 * @param md what to free
217 */ 224 */
218void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData 225void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData
219 *md); 226 *md);
220 227
221/** 228/**
222 * Test if two MDs are equal. 229 * Test if two MDs are equal.
230 *
231 * @param md1 first value to check
232 * @param md2 other value to check
233 * @return GNUNET_YES if they are equal
223 */ 234 */
224int GNUNET_CONTAINER_meta_data_test_equal (const struct 235int GNUNET_CONTAINER_meta_data_test_equal (const struct
225 GNUNET_CONTAINER_MetaData *md1, 236 GNUNET_CONTAINER_MetaData *md1,
@@ -229,6 +240,10 @@ int GNUNET_CONTAINER_meta_data_test_equal (const struct
229 240
230/** 241/**
231 * Extend metadata. 242 * Extend metadata.
243 *
244 * @param md metadata to extend
245 * @param type type of the new entry
246 * @param data value for the entry
232 * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists 247 * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists
233 */ 248 */
234int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, 249int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
@@ -237,6 +252,10 @@ int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
237 252
238/** 253/**
239 * Remove an item. 254 * Remove an item.
255 *
256 * @param type type of the item to remove
257 * @param data specific value to remove, NULL to remove all
258 * entries of the given type
240 * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md 259 * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md
241 */ 260 */
242int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, 261int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
@@ -246,6 +265,8 @@ int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
246/** 265/**
247 * Add the current time as the publication date 266 * Add the current time as the publication date
248 * to the meta-data. 267 * to the meta-data.
268 *
269 * @param md metadata to modify
249 */ 270 */
250void GNUNET_CONTAINER_meta_data_add_publication_date (struct 271void GNUNET_CONTAINER_meta_data_add_publication_date (struct
251 GNUNET_CONTAINER_MetaData 272 GNUNET_CONTAINER_MetaData
@@ -254,6 +275,9 @@ void GNUNET_CONTAINER_meta_data_add_publication_date (struct
254/** 275/**
255 * Iterate over MD entries, excluding thumbnails. 276 * Iterate over MD entries, excluding thumbnails.
256 * 277 *
278 * @param md metadata to inspect
279 * @param iterator function to call on each entry
280 * @param closure closure for iterator
257 * @return number of entries 281 * @return number of entries
258 */ 282 */
259int GNUNET_CONTAINER_meta_data_get_contents (const struct 283int GNUNET_CONTAINER_meta_data_get_contents (const struct
@@ -263,6 +287,9 @@ int GNUNET_CONTAINER_meta_data_get_contents (const struct
263 287
264/** 288/**
265 * Get the first MD entry of the given type. 289 * Get the first MD entry of the given type.
290 *
291 * @param md metadata to inspect
292 * @param type type to look for
266 * @return NULL if we do not have any such entry, 293 * @return NULL if we do not have any such entry,
267 * otherwise client is responsible for freeing the value! 294 * otherwise client is responsible for freeing the value!
268 */ 295 */
@@ -272,7 +299,9 @@ char *GNUNET_CONTAINER_meta_data_get_by_type (const struct
272 299
273/** 300/**
274 * Get the first matching MD entry of the given types. 301 * Get the first matching MD entry of the given types.
275 * @paarm ... -1-terminated list of types 302 *
303 * @param md metadata to inspect
304 * @param ... -1-terminated list of types
276 * @return NULL if we do not have any such entry, 305 * @return NULL if we do not have any such entry,
277 * otherwise client is responsible for freeing the value! 306 * otherwise client is responsible for freeing the value!
278 */ 307 */
@@ -283,6 +312,7 @@ char *GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
283/** 312/**
284 * Get a thumbnail from the meta-data (if present). 313 * Get a thumbnail from the meta-data (if present).
285 * 314 *
315 * @param md metadata to inspect
286 * @param thumb will be set to the thumbnail data. Must be 316 * @param thumb will be set to the thumbnail data. Must be
287 * freed by the caller! 317 * freed by the caller!
288 * @return number of bytes in thumbnail, 0 if not available 318 * @return number of bytes in thumbnail, 0 if not available
@@ -294,6 +324,9 @@ size_t GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
294/** 324/**
295 * Extract meta-data from a file. 325 * Extract meta-data from a file.
296 * 326 *
327 * @param md metadata to set
328 * @param filename name of file to inspect
329 * @param extractors plugins to use
297 * @return GNUNET_SYSERR on error, otherwise the number 330 * @return GNUNET_SYSERR on error, otherwise the number
298 * of meta-data items obtained 331 * of meta-data items obtained
299 */ 332 */
@@ -315,12 +348,13 @@ enum GNUNET_CONTAINER_MetaDataSerializationOptions
315/** 348/**
316 * Serialize meta-data to target. 349 * Serialize meta-data to target.
317 * 350 *
351 * @param md metadata to serialize
318 * @param size maximum number of bytes available 352 * @param size maximum number of bytes available
319 * @param opt is it ok to just write SOME of the 353 * @param opt is it ok to just write SOME of the
320 * meta-data to match the size constraint, 354 * meta-data to match the size constraint,
321 * possibly discarding some data? 355 * possibly discarding some data?
322 * @return number of bytes written on success, 356 * @return number of bytes written on success,
323 * GNUNET_SYSERR on error (typically: not enough 357 * -1 on error (typically: not enough
324 * space) 358 * space)
325 */ 359 */
326ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct 360ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
@@ -334,9 +368,12 @@ ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
334/** 368/**
335 * Compute size of the meta-data in 369 * Compute size of the meta-data in
336 * serialized form. 370 * serialized form.
371 *
372 * @param md metadata to inspect
337 * @param opt is it ok to just write SOME of the 373 * @param opt is it ok to just write SOME of the
338 * meta-data to match the size constraint, 374 * meta-data to match the size constraint,
339 * possibly discarding some data? 375 * possibly discarding some data?
376 * @return number of bytes needed for serialization, -1 on error
340 */ 377 */
341ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct 378ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
342 GNUNET_CONTAINER_MetaData 379 GNUNET_CONTAINER_MetaData
@@ -347,6 +384,8 @@ ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
347 384
348/** 385/**
349 * Deserialize meta-data. Initializes md. 386 * Deserialize meta-data. Initializes md.
387 *
388 * @param input serialized meta-data.
350 * @param size number of bytes available 389 * @param size number of bytes available
351 * @return MD on success, NULL on error (i.e. 390 * @return MD on success, NULL on error (i.e.
352 * bad format) 391 * bad format)
@@ -359,6 +398,7 @@ struct GNUNET_CONTAINER_MetaData
359 * Does the meta-data claim that this is a directory? 398 * Does the meta-data claim that this is a directory?
360 * Checks if the mime-type is that of a GNUnet directory. 399 * Checks if the mime-type is that of a GNUnet directory.
361 * 400 *
401 * @param md metadata to inspect
362 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if 402 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
363 * we have no mime-type information (treat as 'GNUNET_NO') 403 * we have no mime-type information (treat as 'GNUNET_NO')
364 */ 404 */
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 3c71d40e7..f78ed51e5 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -21,6 +21,10 @@
21 * @file include/gnunet_fs_service.h 21 * @file include/gnunet_fs_service.h
22 * @brief API for file-sharing via GNUnet 22 * @brief API for file-sharing via GNUnet
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 *
25 * TODO:
26 * - extend API with support for publish simulation (-s)
27 * and URI-argument binding to keyword/namespace (-u)
24 */ 28 */
25#ifndef GNUNET_FS_LIB_H 29#ifndef GNUNET_FS_LIB_H
26#define GNUNET_FS_LIB_H 30#define GNUNET_FS_LIB_H
@@ -398,7 +402,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
398 * @return GNUNET_OK on success 402 * @return GNUNET_OK on success
399 */ 403 */
400int 404int
401GNUNET_FS_getopt_configure_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx, 405GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
402 void *scls, 406 void *scls,
403 const char *option, 407 const char *option,
404 const char *value); 408 const char *value);
@@ -417,7 +421,7 @@ GNUNET_FS_getopt_configure_set_keywords (struct GNUNET_GETOPT_CommandLineProcess
417 * @return GNUNET_OK on success 421 * @return GNUNET_OK on success
418 */ 422 */
419int 423int
420GNUNET_FS_getopt_configure_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx, 424GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext* ctx,
421 void *scls, 425 void *scls,
422 const char *option, 426 const char *option,
423 const char *value); 427 const char *value);
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index baba3aba8..645353520 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -24,8 +24,8 @@
24 * @author Nils Durner 24 * @author Nils Durner
25 */ 25 */
26 26
27#ifndef GNUNET_NETWORK_LIB_H_ 27#ifndef GNUNET_NETWORK_LIB_H
28#define GNUNET_NETWORK_LIB_H_ 28#define GNUNET_NETWORK_LIB_H
29 29
30#ifdef __cplusplus 30#ifdef __cplusplus
31extern "C" 31extern "C"
@@ -54,6 +54,11 @@ struct GNUNET_NETWORK_Descriptor *GNUNET_NETWORK_socket_accept (const struct GNU
54 struct sockaddr *address, 54 struct sockaddr *address,
55 socklen_t *address_len); 55 socklen_t *address_len);
56 56
57int
58GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Descriptor
59 *desc);
60
61
57int GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Descriptor *desc, 62int GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Descriptor *desc,
58 const struct sockaddr *address, socklen_t address_len); 63 const struct sockaddr *address, socklen_t address_len);
59 64
@@ -128,7 +133,7 @@ int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
128 133
129int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, const struct GNUNET_NETWORK_FDSet *fds2); 134int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, const struct GNUNET_NETWORK_FDSet *fds2);
130 135
131struct GNUNET_NETWORK_FDSet *GNUNET_NETWORK_fdset_create (); 136struct GNUNET_NETWORK_FDSet *GNUNET_NETWORK_fdset_create (void);
132 137
133void GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds); 138void GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds);
134 139
@@ -140,4 +145,4 @@ void GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds);
140} 145}
141#endif 146#endif
142 147
143#endif /* GNUNET_NETWORK_LIB_H_ */ 148#endif /* GNUNET_NETWORK_LIB_H */
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index f6c1783a6..d58d80bac 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -37,6 +37,7 @@ libgnunetutil_la_SOURCES = \
37 getopt.c \ 37 getopt.c \
38 getopt_helpers.c \ 38 getopt_helpers.c \
39 network.c \ 39 network.c \
40 network_socket.c \
40 os_installation.c \ 41 os_installation.c \
41 os_load.c \ 42 os_load.c \
42 os_network.c \ 43 os_network.c \
@@ -49,7 +50,6 @@ libgnunetutil_la_SOURCES = \
49 server_tc.c \ 50 server_tc.c \
50 service.c \ 51 service.c \
51 signal.c \ 52 signal.c \
52 sock.c \
53 strings.c \ 53 strings.c \
54 time.c \ 54 time.c \
55 $(WINSRC) 55 $(WINSRC)
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c
index d80c5fd2b..4cb4ea148 100644
--- a/src/util/container_meta_data.c
+++ b/src/util/container_meta_data.c
@@ -689,6 +689,10 @@ FAILURE:
689 689
690/** 690/**
691 * Test if two MDs are equal. 691 * Test if two MDs are equal.
692 *
693 * @param md1 first value to check
694 * @param md2 other value to check
695 * @return GNUNET_YES if they are equal
692 */ 696 */
693int 697int
694GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData 698GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
diff --git a/src/util/sock.c b/src/util/network_socket.c
index 33b6df148..59afb7246 100644
--- a/src/util/sock.c
+++ b/src/util/network_socket.c
@@ -675,4 +675,4 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
675#endif 675#endif
676} 676}
677 677
678/* end of io.c */ 678/* end of sock.c */