diff options
-rw-r--r-- | BUGS | 1 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | src/fs/gnunet-directory.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_client_lib.h | 5 | ||||
-rw-r--r-- | src/include/gnunet_common.h | 35 | ||||
-rw-r--r-- | src/include/gnunet_container_lib.h | 38 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 61 | ||||
-rw-r--r-- | src/include/gnunet_datastore_service.h | 28 | ||||
-rw-r--r-- | src/include/gnunet_disk_lib.h | 141 | ||||
-rw-r--r-- | src/include/gnunet_getopt_lib.h | 21 | ||||
-rw-r--r-- | src/include/gnunet_network_lib.h | 35 | ||||
-rw-r--r-- | src/include/gnunet_os_lib.h | 50 | ||||
-rw-r--r-- | src/include/gnunet_plugin_lib.h | 10 | ||||
-rw-r--r-- | src/include/gnunet_signal_lib.h | 11 | ||||
-rw-r--r-- | src/include/gnunet_strings_lib.h | 27 | ||||
-rw-r--r-- | src/include/gnunet_time_lib.h | 75 | ||||
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 5 | ||||
-rw-r--r-- | src/util/common_allocation.c | 18 | ||||
-rw-r--r-- | src/util/disk.c | 31 | ||||
-rw-r--r-- | src/util/strings.c | 13 |
20 files changed, 525 insertions, 84 deletions
@@ -115,3 +115,4 @@ sane end-user should care about this codebase yet anyway. | |||
115 | * HOSTLIST: | 115 | * HOSTLIST: |
116 | - implement advertising of hostlist URL | 116 | - implement advertising of hostlist URL |
117 | - implement learning of hostlist URLs | 117 | - implement learning of hostlist URLs |
118 | |||
@@ -177,3 +177,5 @@ Urgent items (before announcing ng.gnunet.org): | |||
177 | * Remove KBlocks in gnunet-unindex (see discussion with Kenneth Almquist on gnunet-devs in 9/2009) | 177 | * Remove KBlocks in gnunet-unindex (see discussion with Kenneth Almquist on gnunet-devs in 9/2009) |
178 | * Allow checking of presence of search results and/or content via command-line tools | 178 | * Allow checking of presence of search results and/or content via command-line tools |
179 | (add options to gnunet-search / gnunet-download to limit search to local peer) | 179 | (add options to gnunet-search / gnunet-download to limit search to local peer) |
180 | * STATISTICS: | ||
181 | - should use BIO instead of mmap | ||
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c index 8fc477614..a5caaa53d 100644 --- a/src/fs/gnunet-directory.c +++ b/src/fs/gnunet-directory.c | |||
@@ -127,7 +127,7 @@ run (void *cls, | |||
127 | len = (size_t) size; | 127 | len = (size_t) size; |
128 | data = GNUNET_DISK_file_map (h, | 128 | data = GNUNET_DISK_file_map (h, |
129 | &map, | 129 | &map, |
130 | GNUNET_DISK_MAP_READ, | 130 | GNUNET_DISK_MAP_TYPE_READ, |
131 | len); | 131 | len); |
132 | GNUNET_assert (NULL != data); | 132 | GNUNET_assert (NULL != data); |
133 | GNUNET_FS_directory_list_contents (len, | 133 | GNUNET_FS_directory_list_contents (len, |
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index fd9291598..17f17ab50 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h | |||
@@ -87,12 +87,13 @@ typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls, | |||
87 | * | 87 | * |
88 | * @param sock the service | 88 | * @param sock the service |
89 | * @param handler function to call with the message | 89 | * @param handler function to call with the message |
90 | * @param cls closure for handler | 90 | * @param handler_cls closure for handler |
91 | * @param timeout how long to wait until timing out | 91 | * @param timeout how long to wait until timing out |
92 | */ | 92 | */ |
93 | void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | 93 | void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, |
94 | GNUNET_CLIENT_MessageHandler handler, | 94 | GNUNET_CLIENT_MessageHandler handler, |
95 | void *cls, struct GNUNET_TIME_Relative timeout); | 95 | void *handler_cls, |
96 | struct GNUNET_TIME_Relative timeout); | ||
96 | 97 | ||
97 | 98 | ||
98 | /** | 99 | /** |
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 614fd3824..402674f48 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2006 Christian Grothoff (and other contributing authors) | 3 | (C) 2006, 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 |
@@ -413,11 +413,23 @@ unsigned long long GNUNET_htonll (unsigned long long n); | |||
413 | 413 | ||
414 | /** | 414 | /** |
415 | * Like snprintf, just aborts if the buffer is of insufficient size. | 415 | * Like snprintf, just aborts if the buffer is of insufficient size. |
416 | * | ||
417 | * @param buf pointer to buffer that is written to | ||
418 | * @param size number of bytes in buf | ||
419 | * @param format format strings | ||
420 | * @param ... data for format string | ||
421 | * @return number of bytes written to buf or negative value on error | ||
416 | */ | 422 | */ |
417 | int GNUNET_snprintf (char *buf, size_t size, const char *format, ...); | 423 | int GNUNET_snprintf (char *buf, size_t size, const char *format, ...); |
418 | 424 | ||
425 | |||
419 | /** | 426 | /** |
420 | * Like asprintf, just portable. | 427 | * Like asprintf, just portable. |
428 | * | ||
429 | * @param buf set to a buffer of sufficient size (allocated, caller must free) | ||
430 | * @param format format string (see printf, fprintf, etc.) | ||
431 | * @param ... data for format string | ||
432 | * @return number of bytes in "*buf" excluding 0-termination | ||
421 | */ | 433 | */ |
422 | int GNUNET_asprintf (char **buf, const char *format, ...); | 434 | int GNUNET_asprintf (char **buf, const char *format, ...); |
423 | 435 | ||
@@ -429,15 +441,26 @@ int GNUNET_asprintf (char **buf, const char *format, ...); | |||
429 | * memory is available. Don't use GNUNET_xmalloc_ directly. Use the | 441 | * memory is available. Don't use GNUNET_xmalloc_ directly. Use the |
430 | * GNUNET_malloc macro. | 442 | * GNUNET_malloc macro. |
431 | * The memory will be zero'ed out. | 443 | * The memory will be zero'ed out. |
444 | * | ||
445 | * @param size number of bytes to allocate | ||
446 | * @param filename where is this call being made (for debugging) | ||
447 | * @param linenumber line where this call is being made (for debugging) | ||
448 | * @return allocated memory, never NULL | ||
432 | */ | 449 | */ |
433 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 450 | void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); |
434 | 451 | ||
452 | |||
435 | /** | 453 | /** |
436 | * Allocate memory. This function does not check if the | 454 | * Allocate memory. This function does not check if the |
437 | * allocation request is within reasonable bounds, allowing | 455 | * allocation request is within reasonable bounds, allowing |
438 | * allocations larger than 40 MB. If you don't expect the | 456 | * allocations larger than 40 MB. If you don't expect the |
439 | * possibility of very large allocations, use GNUNET_malloc instead. | 457 | * possibility of very large allocations, use GNUNET_malloc instead. |
440 | * The memory will be zero'ed out. | 458 | * The memory will be zero'ed out. |
459 | * | ||
460 | * @param size number of bytes to allocate | ||
461 | * @param filename where is this call being made (for debugging) | ||
462 | * @param linenumber line where this call is being made (for debugging) | ||
463 | * @return allocated memory, never NULL | ||
441 | */ | 464 | */ |
442 | void *GNUNET_xmalloc_unchecked_ (size_t size, | 465 | void *GNUNET_xmalloc_unchecked_ (size_t size, |
443 | const char *filename, int linenumber); | 466 | const char *filename, int linenumber); |
@@ -453,12 +476,20 @@ void *GNUNET_xrealloc_ (void *ptr, | |||
453 | * Free memory. Merely a wrapper for the case that we | 476 | * Free memory. Merely a wrapper for the case that we |
454 | * want to keep track of allocations. Don't use GNUNET_xfree_ | 477 | * want to keep track of allocations. Don't use GNUNET_xfree_ |
455 | * directly. Use the GNUNET_free macro. | 478 | * directly. Use the GNUNET_free macro. |
479 | * | ||
480 | * @param ptr pointer to memory to free | ||
481 | * @param filename where is this call being made (for debugging) | ||
482 | * @param linenumber line where this call is being made (for debugging) | ||
456 | */ | 483 | */ |
457 | void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | 484 | void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); |
458 | 485 | ||
459 | 486 | ||
460 | /** | 487 | /** |
461 | * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. | 488 | * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. |
489 | * @param str string to duplicate | ||
490 | * @param filename where is this call being made (for debugging) | ||
491 | * @param linenumber line where this call is being made (for debugging) | ||
492 | * @return the duplicated string | ||
462 | */ | 493 | */ |
463 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | 494 | char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); |
464 | 495 | ||
@@ -474,6 +505,8 @@ char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | |||
474 | * @param elementSize the size of the elements of the array | 505 | * @param elementSize the size of the elements of the array |
475 | * @param oldCount address of the number of elements in the *old array | 506 | * @param oldCount address of the number of elements in the *old array |
476 | * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) | 507 | * @param newCount number of elements in the new array, may be 0 (then *old will be NULL afterwards) |
508 | * @param filename where is this call being made (for debugging) | ||
509 | * @param linenumber line where this call is being made (for debugging) | ||
477 | */ | 510 | */ |
478 | void GNUNET_xgrow_ (void **old, | 511 | void GNUNET_xgrow_ (void **old, |
479 | size_t elementSize, | 512 | size_t elementSize, |
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 61dee9918..b376af3c8 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -344,15 +344,30 @@ int GNUNET_CONTAINER_meta_data_extract_from_file (struct | |||
344 | EXTRACTOR_ExtractorList * | 344 | EXTRACTOR_ExtractorList * |
345 | extractors); | 345 | extractors); |
346 | 346 | ||
347 | |||
348 | /** | ||
349 | * Options for metadata serialization. | ||
350 | */ | ||
347 | enum GNUNET_CONTAINER_MetaDataSerializationOptions | 351 | enum GNUNET_CONTAINER_MetaDataSerializationOptions |
348 | { | 352 | { |
353 | /** | ||
354 | * Serialize all of the data. | ||
355 | */ | ||
349 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0, | 356 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0, |
357 | |||
358 | /** | ||
359 | * If not enough space is available, it is acceptable | ||
360 | * to only serialize some of the metadata. | ||
361 | */ | ||
350 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1, | 362 | GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1, |
363 | |||
364 | /** | ||
365 | * Speed is of the essence, do not allow compression. | ||
366 | */ | ||
351 | GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2 | 367 | GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2 |
352 | }; | 368 | }; |
353 | 369 | ||
354 | 370 | ||
355 | |||
356 | /** | 371 | /** |
357 | * Serialize meta-data to target. | 372 | * Serialize meta-data to target. |
358 | * | 373 | * |
@@ -631,6 +646,10 @@ void *GNUNET_CONTAINER_multihashmap_get_random (const struct | |||
631 | * Insert an element into a DLL. Assumes | 646 | * Insert an element into a DLL. Assumes |
632 | * that head, tail and element are structs | 647 | * that head, tail and element are structs |
633 | * with prev and next fields. | 648 | * with prev and next fields. |
649 | * | ||
650 | * @param head pointer to the head of the DLL | ||
651 | * @param tail pointer to the tail of the DLL | ||
652 | * @param element element to insert | ||
634 | */ | 653 | */ |
635 | #define GNUNET_CONTAINER_DLL_insert(head,tail,element) \ | 654 | #define GNUNET_CONTAINER_DLL_insert(head,tail,element) \ |
636 | (element)->next = (head); \ | 655 | (element)->next = (head); \ |
@@ -645,6 +664,11 @@ void *GNUNET_CONTAINER_multihashmap_get_random (const struct | |||
645 | * Insert an element into a DLL after the given other | 664 | * Insert an element into a DLL after the given other |
646 | * element. Insert at the head if the other | 665 | * element. Insert at the head if the other |
647 | * element is NULL. | 666 | * element is NULL. |
667 | * | ||
668 | * @param head pointer to the head of the DLL | ||
669 | * @param tail pointer to the tail of the DLL | ||
670 | * @param other prior element, NULL for insertion at head of DLL | ||
671 | * @param element element to insert | ||
648 | */ | 672 | */ |
649 | #define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) \ | 673 | #define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) \ |
650 | (element)->prev = (other); \ | 674 | (element)->prev = (other); \ |
@@ -670,6 +694,10 @@ void *GNUNET_CONTAINER_multihashmap_get_random (const struct | |||
670 | * Remove an element from a DLL. Assumes | 694 | * Remove an element from a DLL. Assumes |
671 | * that head, tail and element are structs | 695 | * that head, tail and element are structs |
672 | * with prev and next fields. | 696 | * with prev and next fields. |
697 | * | ||
698 | * @param head pointer to the head of the DLL | ||
699 | * @param tail pointer to the tail of the DLL | ||
700 | * @param element element to remove | ||
673 | */ | 701 | */ |
674 | #define GNUNET_CONTAINER_DLL_remove(head,tail,element) \ | 702 | #define GNUNET_CONTAINER_DLL_remove(head,tail,element) \ |
675 | if ((element)->prev == NULL) \ | 703 | if ((element)->prev == NULL) \ |
@@ -766,6 +794,9 @@ int GNUNET_CONTAINER_heap_iterate (struct GNUNET_CONTAINER_Heap *heap, | |||
766 | /** | 794 | /** |
767 | * Inserts a new item into the heap, item is always neighbor now. | 795 | * Inserts a new item into the heap, item is always neighbor now. |
768 | * @param heap the heap | 796 | * @param heap the heap |
797 | * @param element element to insert | ||
798 | * @param cost cost of the element | ||
799 | * @return FIXME | ||
769 | */ | 800 | */ |
770 | int | 801 | int |
771 | GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, | 802 | GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, |
@@ -795,7 +826,10 @@ void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap); | |||
795 | * Removes any node from the tree based on the neighbor given, does | 826 | * Removes any node from the tree based on the neighbor given, does |
796 | * not traverse the tree (backpointers) but may take more time due to | 827 | * not traverse the tree (backpointers) but may take more time due to |
797 | * percolation of nodes. | 828 | * percolation of nodes. |
829 | * | ||
798 | * @param heap the heap | 830 | * @param heap the heap |
831 | * @param element element to remove | ||
832 | * @return FIXME | ||
799 | */ | 833 | */ |
800 | void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap, | 834 | void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap, |
801 | void *element); | 835 | void *element); |
@@ -807,7 +841,7 @@ void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap, | |||
807 | * @param heap the heap | 841 | * @param heap the heap |
808 | * @param element the element for which the cost is updated | 842 | * @param element the element for which the cost is updated |
809 | * @param new_cost new cost for the element | 843 | * @param new_cost new cost for the element |
810 | * @return WHAT? | 844 | * @return FIXME |
811 | */ | 845 | */ |
812 | int | 846 | int |
813 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | 847 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 9303aa98c..9b795cc75 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -43,10 +43,20 @@ extern "C" | |||
43 | #include "gnunet_common.h" | 43 | #include "gnunet_common.h" |
44 | #include "gnunet_scheduler_lib.h" | 44 | #include "gnunet_scheduler_lib.h" |
45 | 45 | ||
46 | 46 | /** | |
47 | * Desired quality level for cryptographic operations. | ||
48 | */ | ||
47 | enum GNUNET_CRYPTO_Quality | 49 | enum GNUNET_CRYPTO_Quality |
48 | { | 50 | { |
51 | /** | ||
52 | * No good quality of the operation is needed (i.e., | ||
53 | * random numbers can be pseudo-random). | ||
54 | */ | ||
49 | GNUNET_CRYPTO_QUALITY_WEAK, | 55 | GNUNET_CRYPTO_QUALITY_WEAK, |
56 | |||
57 | /** | ||
58 | * High-quality operations are desired. | ||
59 | */ | ||
50 | GNUNET_CRYPTO_QUALITY_STRONG | 60 | GNUNET_CRYPTO_QUALITY_STRONG |
51 | }; | 61 | }; |
52 | 62 | ||
@@ -242,6 +252,8 @@ unsigned int *GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, | |||
242 | 252 | ||
243 | /** | 253 | /** |
244 | * Create a new Session key. | 254 | * Create a new Session key. |
255 | * | ||
256 | * @param key key to initialize | ||
245 | */ | 257 | */ |
246 | void GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey | 258 | void GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey |
247 | *key); | 259 | *key); |
@@ -250,6 +262,7 @@ void GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey | |||
250 | /** | 262 | /** |
251 | * Check that a new session key is well-formed. | 263 | * Check that a new session key is well-formed. |
252 | * | 264 | * |
265 | * @param key key to check | ||
253 | * @return GNUNET_OK if the key is valid | 266 | * @return GNUNET_OK if the key is valid |
254 | */ | 267 | */ |
255 | int GNUNET_CRYPTO_aes_check_session_key (const struct | 268 | int GNUNET_CRYPTO_aes_check_session_key (const struct |
@@ -320,6 +333,9 @@ int GNUNET_CRYPTO_hash_from_string (const char *enc, | |||
320 | * a.a or a.e (they're used elsewhere), and | 333 | * a.a or a.e (they're used elsewhere), and |
321 | * be somewhat consistent. And of course, the | 334 | * be somewhat consistent. And of course, the |
322 | * result should be a positive number. | 335 | * result should be a positive number. |
336 | * | ||
337 | * @param a some hash code | ||
338 | * @param b some hash code | ||
323 | * @return number between 0 and 65536 | 339 | * @return number between 0 and 65536 |
324 | */ | 340 | */ |
325 | uint32_t GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a, | 341 | uint32_t GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a, |
@@ -372,6 +388,9 @@ void GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, | |||
372 | 388 | ||
373 | /** | 389 | /** |
374 | * Create a random hash code. | 390 | * Create a random hash code. |
391 | * | ||
392 | * @param mode desired quality level | ||
393 | * @param result hash code that is randomized | ||
375 | */ | 394 | */ |
376 | void GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, | 395 | void GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, |
377 | GNUNET_HashCode * result); | 396 | GNUNET_HashCode * result); |
@@ -379,6 +398,10 @@ void GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, | |||
379 | 398 | ||
380 | /** | 399 | /** |
381 | * compute result(delta) = b - a | 400 | * compute result(delta) = b - a |
401 | * | ||
402 | * @param a some hash code | ||
403 | * @param b some hash code | ||
404 | * @param result set to b - a | ||
382 | */ | 405 | */ |
383 | void GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a, | 406 | void GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a, |
384 | const GNUNET_HashCode * b, | 407 | const GNUNET_HashCode * b, |
@@ -387,6 +410,10 @@ void GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a, | |||
387 | 410 | ||
388 | /** | 411 | /** |
389 | * compute result(b) = a + delta | 412 | * compute result(b) = a + delta |
413 | * | ||
414 | * @param a some hash code | ||
415 | * @param delta some hash code | ||
416 | * @param result set to a + delta | ||
390 | */ | 417 | */ |
391 | void GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, | 418 | void GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, |
392 | const GNUNET_HashCode * delta, | 419 | const GNUNET_HashCode * delta, |
@@ -395,6 +422,10 @@ void GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, | |||
395 | 422 | ||
396 | /** | 423 | /** |
397 | * compute result = a ^ b | 424 | * compute result = a ^ b |
425 | * | ||
426 | * @param a some hash code | ||
427 | * @param b some hash code | ||
428 | * @param result set to a ^ b | ||
398 | */ | 429 | */ |
399 | void GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, | 430 | void GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, |
400 | const GNUNET_HashCode * b, | 431 | const GNUNET_HashCode * b, |
@@ -403,6 +434,10 @@ void GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, | |||
403 | 434 | ||
404 | /** | 435 | /** |
405 | * Convert a hashcode into a key. | 436 | * Convert a hashcode into a key. |
437 | * | ||
438 | * @param hc hash code that serves to generate the key | ||
439 | * @param skey set to a valid session key | ||
440 | * @param iv set to a valid initialization vector | ||
406 | */ | 441 | */ |
407 | void GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc, | 442 | void GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc, |
408 | struct GNUNET_CRYPTO_AesSessionKey *skey, | 443 | struct GNUNET_CRYPTO_AesSessionKey *skey, |
@@ -413,6 +448,7 @@ void GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc, | |||
413 | 448 | ||
414 | /** | 449 | /** |
415 | * Obtain a bit from a hashcode. | 450 | * Obtain a bit from a hashcode. |
451 | * | ||
416 | * @param code the GNUNET_CRYPTO_hash to index bit-wise | 452 | * @param code the GNUNET_CRYPTO_hash to index bit-wise |
417 | * @param bit index into the hashcode, [0...159] | 453 | * @param bit index into the hashcode, [0...159] |
418 | * @return Bit \a bit from hashcode \a code, -1 for invalid index | 454 | * @return Bit \a bit from hashcode \a code, -1 for invalid index |
@@ -424,6 +460,9 @@ int GNUNET_CRYPTO_hash_get_bit (const GNUNET_HashCode * code, | |||
424 | /** | 460 | /** |
425 | * Compare function for HashCodes, producing a total ordering | 461 | * Compare function for HashCodes, producing a total ordering |
426 | * of all hashcodes. | 462 | * of all hashcodes. |
463 | * | ||
464 | * @param h1 some hash code | ||
465 | * @param h2 some hash code | ||
427 | * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. | 466 | * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2. |
428 | */ | 467 | */ |
429 | int GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1, | 468 | int GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1, |
@@ -433,6 +472,10 @@ int GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1, | |||
433 | /** | 472 | /** |
434 | * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target | 473 | * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target |
435 | * in the XOR metric (Kademlia). | 474 | * in the XOR metric (Kademlia). |
475 | * | ||
476 | * @param h1 some hash code | ||
477 | * @param h2 some hash code | ||
478 | * @param target some hash code | ||
436 | * @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2. | 479 | * @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2. |
437 | */ | 480 | */ |
438 | int GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1, | 481 | int GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1, |
@@ -442,6 +485,8 @@ int GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1, | |||
442 | 485 | ||
443 | /** | 486 | /** |
444 | * Create a new private key. Caller must free return value. | 487 | * Create a new private key. Caller must free return value. |
488 | * | ||
489 | * @return fresh private key | ||
445 | */ | 490 | */ |
446 | struct GNUNET_CRYPTO_RsaPrivateKey *GNUNET_CRYPTO_rsa_key_create (void); | 491 | struct GNUNET_CRYPTO_RsaPrivateKey *GNUNET_CRYPTO_rsa_key_create (void); |
447 | 492 | ||
@@ -458,6 +503,7 @@ struct GNUNET_CRYPTO_RsaPrivateKey *GNUNET_CRYPTO_rsa_key_create (void); | |||
458 | * are invalid the old file is deleted and a fresh key is | 503 | * are invalid the old file is deleted and a fresh key is |
459 | * created. | 504 | * created. |
460 | * | 505 | * |
506 | * @param filename name of file to use for storage | ||
461 | * @return new private key, NULL on error (for example, | 507 | * @return new private key, NULL on error (for example, |
462 | * permission denied) | 508 | * permission denied) |
463 | */ | 509 | */ |
@@ -468,6 +514,9 @@ struct GNUNET_CRYPTO_RsaPrivateKey | |||
468 | /** | 514 | /** |
469 | * Deterministically (!) create a private key using only the | 515 | * Deterministically (!) create a private key using only the |
470 | * given HashCode as input to the PRNG. | 516 | * given HashCode as input to the PRNG. |
517 | * | ||
518 | * @param input "random" input to PRNG | ||
519 | * @return some private key purely dependent on input | ||
471 | */ | 520 | */ |
472 | struct GNUNET_CRYPTO_RsaPrivateKey | 521 | struct GNUNET_CRYPTO_RsaPrivateKey |
473 | *GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * input); | 522 | *GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * input); |
@@ -482,13 +531,15 @@ void GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey); | |||
482 | 531 | ||
483 | /** | 532 | /** |
484 | * Extract the public key of the host. | 533 | * Extract the public key of the host. |
485 | * @param result where to write the result. | 534 | * |
535 | * @param priv the private key | ||
536 | * @param pub where to write the public key | ||
486 | */ | 537 | */ |
487 | void GNUNET_CRYPTO_rsa_key_get_public (const struct | 538 | void GNUNET_CRYPTO_rsa_key_get_public (const struct |
488 | GNUNET_CRYPTO_RsaPrivateKey *hostkey, | 539 | GNUNET_CRYPTO_RsaPrivateKey *priv, |
489 | struct | 540 | struct |
490 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 541 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
491 | *result); | 542 | *pub); |
492 | 543 | ||
493 | 544 | ||
494 | /** | 545 | /** |
@@ -562,7 +613,7 @@ int GNUNET_CRYPTO_rsa_verify (uint32_t purpose, | |||
562 | /** | 613 | /** |
563 | * This function should only be called in testcases | 614 | * This function should only be called in testcases |
564 | * where strong entropy gathering is not desired | 615 | * where strong entropy gathering is not desired |
565 | * (for example, for hostkey generation). | 616 | * (for example, for hostkey generation). |
566 | */ | 617 | */ |
567 | void GNUNET_CRYPTO_random_disable_entropy_gathering (void); | 618 | void GNUNET_CRYPTO_random_disable_entropy_gathering (void); |
568 | 619 | ||
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index bcc89a8e1..aa35c82ee 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h | |||
@@ -41,14 +41,42 @@ extern "C" | |||
41 | #endif | 41 | #endif |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /** | ||
45 | * FIXME. | ||
46 | */ | ||
44 | #define GNUNET_DATASTORE_BLOCKTYPE_ANY 0 | 47 | #define GNUNET_DATASTORE_BLOCKTYPE_ANY 0 |
48 | |||
49 | /** | ||
50 | * FIXME. | ||
51 | */ | ||
45 | #define GNUNET_DATASTORE_BLOCKTYPE_DBLOCK 1 | 52 | #define GNUNET_DATASTORE_BLOCKTYPE_DBLOCK 1 |
53 | |||
54 | /** | ||
55 | * FIXME. | ||
56 | */ | ||
46 | #define GNUNET_DATASTORE_BLOCKTYPE_IBLOCK 2 | 57 | #define GNUNET_DATASTORE_BLOCKTYPE_IBLOCK 2 |
58 | |||
59 | /** | ||
60 | * FIXME. | ||
61 | */ | ||
47 | #define GNUNET_DATASTORE_BLOCKTYPE_KBLOCK 3 | 62 | #define GNUNET_DATASTORE_BLOCKTYPE_KBLOCK 3 |
63 | |||
64 | /** | ||
65 | * FIXME. | ||
66 | */ | ||
48 | #define GNUNET_DATASTORE_BLOCKTYPE_SBLOCK 4 | 67 | #define GNUNET_DATASTORE_BLOCKTYPE_SBLOCK 4 |
68 | |||
69 | /** | ||
70 | * FIXME. | ||
71 | */ | ||
49 | #define GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND 5 | 72 | #define GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND 5 |
73 | |||
74 | /** | ||
75 | * FIXME. | ||
76 | */ | ||
50 | #define GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK 6 /* not yet used */ | 77 | #define GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK 6 /* not yet used */ |
51 | 78 | ||
79 | |||
52 | /** | 80 | /** |
53 | * Handle to the datastore service. | 81 | * Handle to the datastore service. |
54 | */ | 82 | */ |
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 4d09d4c99..137d4a452 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -53,25 +53,70 @@ extern "C" | |||
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | /* Open the file for reading */ | 56 | /** |
57 | #define GNUNET_DISK_OPEN_READ 1 | 57 | * Specifies how a file should be opened. |
58 | /* Open the file for writing */ | 58 | */ |
59 | #define GNUNET_DISK_OPEN_WRITE 2 | 59 | enum GNUNET_DISK_OpenFlags |
60 | /* Open the file for both reading and writing */ | 60 | { |
61 | #define GNUNET_DISK_OPEN_READWRITE 3 | 61 | |
62 | /* Fail if file already exists */ | 62 | /** |
63 | #define GNUNET_DISK_OPEN_FAILIFEXISTS 4 | 63 | * Open the file for reading |
64 | /* Truncate file if it exists */ | 64 | */ |
65 | #define GNUNET_DISK_OPEN_TRUNCATE 8 | 65 | GNUNET_DISK_OPEN_READ = 1, |
66 | /* Create file if it doesn't exist */ | 66 | |
67 | #define GNUNET_DISK_OPEN_CREATE 16 | 67 | /** |
68 | /* Append to the file */ | 68 | * Open the file for writing |
69 | #define GNUNET_DISK_OPEN_APPEND 32 | 69 | */ |
70 | 70 | GNUNET_DISK_OPEN_WRITE = 2, | |
71 | #define GNUNET_DISK_MAP_READ 1 | 71 | |
72 | #define GNUNET_DISK_MAP_WRITE 2 | 72 | /** |
73 | #define GNUNET_DISK_MAP_READWRITE 3 | 73 | * Open the file for both reading and writing |
74 | */ | ||
75 | GNUNET_DISK_OPEN_READWRITE = 3, | ||
76 | |||
77 | /** | ||
78 | * Fail if file already exists | ||
79 | */ | ||
80 | GNUNET_DISK_OPEN_FAILIFEXISTS = 4, | ||
81 | |||
82 | /** | ||
83 | * Truncate file if it exists | ||
84 | */ | ||
85 | GNUNET_DISK_OPEN_TRUNCATE = 8, | ||
86 | |||
87 | /** | ||
88 | * Create file if it doesn't exist | ||
89 | */ | ||
90 | GNUNET_DISK_OPEN_CREATE = 16, | ||
91 | |||
92 | /** | ||
93 | * Append to the file | ||
94 | */ | ||
95 | GNUNET_DISK_OPEN_APPEND = 32 | ||
96 | }; | ||
74 | 97 | ||
98 | /** | ||
99 | * Specifies what type of memory map is desired. | ||
100 | */ | ||
101 | enum GNUNET_DISK_MapType | ||
102 | { | ||
103 | /** | ||
104 | * Read-only memory map. | ||
105 | */ | ||
106 | GNUNET_DISK_MAP_TYPE_READ = 1, | ||
107 | |||
108 | /** | ||
109 | * Write-able memory map. | ||
110 | */ | ||
111 | GNUNET_DISK_MAP_TYPE_WRITE = 2, | ||
112 | /** | ||
113 | * Read-write memory map. | ||
114 | */ | ||
115 | GNUNET_DISK_MAP_TYPE_READWRITE = 3 | ||
116 | }; | ||
117 | |||
118 | |||
119 | // FIXME: use enum here! | ||
75 | #define GNUNET_DISK_PERM_USER_READ 1 | 120 | #define GNUNET_DISK_PERM_USER_READ 1 |
76 | #define GNUNET_DISK_PERM_USER_WRITE 2 | 121 | #define GNUNET_DISK_PERM_USER_WRITE 2 |
77 | #define GNUNET_DISK_PERM_USER_EXEC 4 | 122 | #define GNUNET_DISK_PERM_USER_EXEC 4 |
@@ -82,10 +127,24 @@ extern "C" | |||
82 | #define GNUNET_DISK_PERM_OTHER_WRITE 128 | 127 | #define GNUNET_DISK_PERM_OTHER_WRITE 128 |
83 | #define GNUNET_DISK_PERM_OTHER_EXEC 256 | 128 | #define GNUNET_DISK_PERM_OTHER_EXEC 256 |
84 | 129 | ||
130 | /** | ||
131 | * Constants for specifying how to seek. | ||
132 | */ | ||
85 | enum GNUNET_DISK_Seek | 133 | enum GNUNET_DISK_Seek |
86 | { | 134 | { |
135 | /** | ||
136 | * Seek an absolute position (from the start of the file). | ||
137 | */ | ||
87 | GNUNET_DISK_SEEK_SET, | 138 | GNUNET_DISK_SEEK_SET, |
139 | |||
140 | /** | ||
141 | * Seek a relative position (from the current offset). | ||
142 | */ | ||
88 | GNUNET_DISK_SEEK_CUR, | 143 | GNUNET_DISK_SEEK_CUR, |
144 | |||
145 | /** | ||
146 | * Seek an absolute position from the end of the file. | ||
147 | */ | ||
89 | GNUNET_DISK_SEEK_END | 148 | GNUNET_DISK_SEEK_END |
90 | }; | 149 | }; |
91 | 150 | ||
@@ -111,7 +170,8 @@ int GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); | |||
111 | * Check that fil corresponds to a filename | 170 | * Check that fil corresponds to a filename |
112 | * (of a file that exists and that is not a directory). | 171 | * (of a file that exists and that is not a directory). |
113 | * | 172 | * |
114 | * @returns GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if something | 173 | * @param fil filename to check |
174 | * @return GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if something | ||
115 | * else (will print an error message in that case, too). | 175 | * else (will print an error message in that case, too). |
116 | */ | 176 | */ |
117 | int GNUNET_DISK_file_test (const char *fil); | 177 | int GNUNET_DISK_file_test (const char *fil); |
@@ -149,7 +209,14 @@ int GNUNET_DISK_file_size (const char *filename, | |||
149 | 209 | ||
150 | 210 | ||
151 | /** | 211 | /** |
152 | * FIXME. | 212 | * Obtain some unique identifiers for the given file |
213 | * that can be used to identify it in the local system. | ||
214 | * This function is used between GNUnet processes to | ||
215 | * quickly check if two files with the same absolute path | ||
216 | * are actually identical. The two processes represent | ||
217 | * the same peer but may communicate over the network | ||
218 | * (and the file may be on an NFS volume). This function | ||
219 | * may not be supported on all operating systems. | ||
153 | * | 220 | * |
154 | * @param filename name of the file | 221 | * @param filename name of the file |
155 | * @param dev set to the device ID | 222 | * @param dev set to the device ID |
@@ -170,17 +237,20 @@ int GNUNET_DISK_file_get_identifiers (const char *filename, | |||
170 | * file on disk in directory for temporary files | 237 | * file on disk in directory for temporary files |
171 | */ | 238 | */ |
172 | char * | 239 | char * |
173 | GNUNET_DISK_mktemp (const char *t); | 240 | GNUNET_DISK_mktemp (const char *template); |
174 | 241 | ||
175 | 242 | ||
176 | /** | 243 | /** |
177 | * Open a file | 244 | * Open a file. |
245 | * | ||
178 | * @param fn file name to be opened | 246 | * @param fn file name to be opened |
179 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags | 247 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags |
180 | * @param perm permissions for the newly created file | 248 | * @param ... permissions for the newly created file (only required if creation is possible) |
181 | * @return IO handle on success, NULL on error | 249 | * @return IO handle on success, NULL on error |
182 | */ | 250 | */ |
183 | struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn, int flags, ...); | 251 | struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn, |
252 | enum GNUNET_DISK_OpenFlags flags, | ||
253 | ...); | ||
184 | 254 | ||
185 | /** | 255 | /** |
186 | * Creates an interprocess channel | 256 | * Creates an interprocess channel |
@@ -207,7 +277,8 @@ int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); | |||
207 | /** | 277 | /** |
208 | * Get the handle to a particular pipe end | 278 | * Get the handle to a particular pipe end |
209 | * @param p pipe | 279 | * @param p pipe |
210 | * @param n number of the end | 280 | * @param n number of the end (0 or 1); FIXME: use enum here! |
281 | * @return handle for the respective end | ||
211 | */ | 282 | */ |
212 | const struct GNUNET_DISK_FileHandle *GNUNET_DISK_pipe_handle (const struct | 283 | const struct GNUNET_DISK_FileHandle *GNUNET_DISK_pipe_handle (const struct |
213 | GNUNET_DISK_PipeHandle | 284 | GNUNET_DISK_PipeHandle |
@@ -359,6 +430,7 @@ int GNUNET_DISK_directory_create_for_file (const char *filename); | |||
359 | * does not exist. Will log errors if GNUNET_SYSERR is | 430 | * does not exist. Will log errors if GNUNET_SYSERR is |
360 | * returned. | 431 | * returned. |
361 | * | 432 | * |
433 | * @param fil filename to test | ||
362 | * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR | 434 | * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR |
363 | * on any error and if exists but not directory | 435 | * on any error and if exists but not directory |
364 | */ | 436 | */ |
@@ -385,22 +457,24 @@ int GNUNET_DISK_directory_create (const char *dir); | |||
385 | 457 | ||
386 | 458 | ||
387 | /** | 459 | /** |
388 | * Lock a part of a file | 460 | * Lock a part of a file. |
461 | * | ||
389 | * @param fh file handle | 462 | * @param fh file handle |
390 | * @lockStart absolute position from where to lock | 463 | * @param lockStart absolute position from where to lock |
391 | * @lockEnd absolute position until where to lock | 464 | * @param lockEnd absolute position until where to lock |
392 | * @excl GNUNET_YES for an exclusive lock | 465 | * @param excl GNUNET_YES for an exclusive lock |
393 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 466 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
394 | */ | 467 | */ |
395 | int | 468 | int |
396 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | 469 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, |
397 | off_t lockEnd, int excl); | 470 | off_t lockEnd, int excl); |
398 | 471 | ||
472 | |||
399 | /** | 473 | /** |
400 | * Unlock a part of a file | 474 | * Unlock a part of a file |
401 | * @param fh file handle | 475 | * @param fh file handle |
402 | * @lockStart absolute position from where to unlock | 476 | * @param lockStart absolute position from where to unlock |
403 | * @lockEnd absolute position until where to unlock | 477 | * @param lockEnd absolute position until where to unlock |
404 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 478 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
405 | */ | 479 | */ |
406 | int | 480 | int |
@@ -431,6 +505,7 @@ int GNUNET_DISK_file_change_owner (const char *filename, const char *user); | |||
431 | * a directory, end the last argument in '/' (or pass | 505 | * a directory, end the last argument in '/' (or pass |
432 | * DIR_SEPARATOR_STR as the last argument before NULL). | 506 | * DIR_SEPARATOR_STR as the last argument before NULL). |
433 | * | 507 | * |
508 | * @param cfg configuration to use | ||
434 | * @param serviceName name of the service asking | 509 | * @param serviceName name of the service asking |
435 | * @param varargs is NULL-terminated list of | 510 | * @param varargs is NULL-terminated list of |
436 | * path components to append to the | 511 | * path components to append to the |
@@ -450,13 +525,13 @@ struct GNUNET_DISK_MapHandle; | |||
450 | * Map a file into memory | 525 | * Map a file into memory |
451 | * @param h open file handle | 526 | * @param h open file handle |
452 | * @param m handle to the new mapping (will be set) | 527 | * @param m handle to the new mapping (will be set) |
453 | * @param access access specification, GNUNET_DISK_MAP_xxx | 528 | * @param access access specification, GNUNET_DISK_MAP_TYPE_xxx |
454 | * @param len size of the mapping | 529 | * @param len size of the mapping |
455 | * @return pointer to the mapped memory region, NULL on failure | 530 | * @return pointer to the mapped memory region, NULL on failure |
456 | */ | 531 | */ |
457 | void *GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, | 532 | void *GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, |
458 | struct GNUNET_DISK_MapHandle **m, | 533 | struct GNUNET_DISK_MapHandle **m, |
459 | int access, size_t len); | 534 | enum GNUNET_DISK_MapType access, size_t len); |
460 | 535 | ||
461 | /** | 536 | /** |
462 | * Unmap a file | 537 | * Unmap a file |
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 35db3f6d1..44525e2f2 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h | |||
@@ -197,22 +197,37 @@ int GNUNET_GETOPT_run (const char *binaryName, | |||
197 | const struct GNUNET_GETOPT_CommandLineOption | 197 | const struct GNUNET_GETOPT_CommandLineOption |
198 | *allOptions, unsigned int argc, char *const *argv); | 198 | *allOptions, unsigned int argc, char *const *argv); |
199 | 199 | ||
200 | /** | ||
201 | * FIXME | ||
202 | */ | ||
200 | int GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext | 203 | int GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext |
201 | *ctx, void *scls, const char *option, | 204 | *ctx, void *scls, const char *option, |
202 | const char *value); | 205 | const char *value); |
203 | 206 | ||
207 | /** | ||
208 | * FIXME | ||
209 | */ | ||
204 | int GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext | 210 | int GNUNET_GETOPT_set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext |
205 | *ctx, void *scls, const char *option, | 211 | *ctx, void *scls, const char *option, |
206 | const char *value); | 212 | const char *value); |
207 | 213 | ||
214 | /** | ||
215 | * FIXME | ||
216 | */ | ||
208 | int GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext | 217 | int GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext |
209 | *ctx, void *scls, const char *option, | 218 | *ctx, void *scls, const char *option, |
210 | const char *value); | 219 | const char *value); |
211 | 220 | ||
221 | /** | ||
222 | * FIXME | ||
223 | */ | ||
212 | int GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext | 224 | int GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext |
213 | *ctx, void *scls, const char *option, | 225 | *ctx, void *scls, const char *option, |
214 | const char *value); | 226 | const char *value); |
215 | 227 | ||
228 | /** | ||
229 | * FIXME | ||
230 | */ | ||
216 | int | 231 | int |
217 | GNUNET_GETOPT_increment_value (struct | 232 | GNUNET_GETOPT_increment_value (struct |
218 | GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 233 | GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
@@ -221,11 +236,17 @@ GNUNET_GETOPT_increment_value (struct | |||
221 | 236 | ||
222 | /* *************** internal prototypes - use macros above! ************* */ | 237 | /* *************** internal prototypes - use macros above! ************* */ |
223 | 238 | ||
239 | /** | ||
240 | * FIXME | ||
241 | */ | ||
224 | int GNUNET_GETOPT_format_help_ (struct | 242 | int GNUNET_GETOPT_format_help_ (struct |
225 | GNUNET_GETOPT_CommandLineProcessorContext | 243 | GNUNET_GETOPT_CommandLineProcessorContext |
226 | *ctx, void *scls, const char *option, | 244 | *ctx, void *scls, const char *option, |
227 | const char *value); | 245 | const char *value); |
228 | 246 | ||
247 | /** | ||
248 | * FIXME | ||
249 | */ | ||
229 | int GNUNET_GETOPT_print_version_ (struct | 250 | int GNUNET_GETOPT_print_version_ (struct |
230 | GNUNET_GETOPT_CommandLineProcessorContext | 251 | GNUNET_GETOPT_CommandLineProcessorContext |
231 | *ctx, void *scls, const char *option, | 252 | *ctx, void *scls, const char *option, |
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 97fcf2618..492713c46 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h | |||
@@ -65,7 +65,9 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, | |||
65 | socklen_t *address_len); | 65 | socklen_t *address_len); |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Make a non-inheritable to child processes | 68 | * Make a non-inheritable to child processes (sets the |
69 | * close-on-exec flag). | ||
70 | * | ||
69 | * @param socket | 71 | * @param socket |
70 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 72 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise |
71 | * @warning Not implemented on Windows | 73 | * @warning Not implemented on Windows |
@@ -123,10 +125,12 @@ int GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, int | |||
123 | 125 | ||
124 | /** | 126 | /** |
125 | * Read data from a connected socket | 127 | * Read data from a connected socket |
128 | * | ||
126 | * @param desc socket | 129 | * @param desc socket |
127 | * @param buffer buffer | 130 | * @param buffer buffer |
128 | * @param length length of buffer | 131 | * @param length length of buffer |
129 | * @param flags type of message reception | 132 | * @param flags type of message reception |
133 | * @return number of bytes read | ||
130 | */ | 134 | */ |
131 | ssize_t GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, void *buffer, | 135 | ssize_t GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, void *buffer, |
132 | size_t length, int flags); | 136 | size_t length, int flags); |
@@ -149,7 +153,8 @@ int GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
149 | * @param doBlock blocking mode | 153 | * @param doBlock blocking mode |
150 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 154 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
151 | */ | 155 | */ |
152 | int GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock); | 156 | int GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, |
157 | int doBlock); | ||
153 | 158 | ||
154 | /** | 159 | /** |
155 | * Send data | 160 | * Send data |
@@ -207,8 +212,9 @@ int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how) | |||
207 | struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_socket (int domain, int type, int protocol); | 212 | struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_socket (int domain, int type, int protocol); |
208 | 213 | ||
209 | /** | 214 | /** |
210 | * Reset FD set | 215 | * Reset FD set (clears all file descriptors). |
211 | * @param fds fd set | 216 | * |
217 | * @param fds fd set to clear | ||
212 | */ | 218 | */ |
213 | void GNUNET_NETWORK_fdset_zero(struct GNUNET_NETWORK_FDSet *fds); | 219 | void GNUNET_NETWORK_fdset_zero(struct GNUNET_NETWORK_FDSet *fds); |
214 | 220 | ||
@@ -218,7 +224,8 @@ void GNUNET_NETWORK_fdset_zero(struct GNUNET_NETWORK_FDSet *fds); | |||
218 | * @param desc socket to add | 224 | * @param desc socket to add |
219 | */ | 225 | */ |
220 | void GNUNET_NETWORK_fdset_set(struct GNUNET_NETWORK_FDSet *fds, | 226 | void GNUNET_NETWORK_fdset_set(struct GNUNET_NETWORK_FDSet *fds, |
221 | const struct GNUNET_NETWORK_Handle *desc); | 227 | const struct GNUNET_NETWORK_Handle *desc); |
228 | |||
222 | 229 | ||
223 | /** | 230 | /** |
224 | * Check whether a socket is part of the fd set | 231 | * Check whether a socket is part of the fd set |
@@ -226,7 +233,7 @@ void GNUNET_NETWORK_fdset_set(struct GNUNET_NETWORK_FDSet *fds, | |||
226 | * @param desc socket | 233 | * @param desc socket |
227 | */ | 234 | */ |
228 | int GNUNET_NETWORK_fdset_isset(const struct GNUNET_NETWORK_FDSet *fds, | 235 | int GNUNET_NETWORK_fdset_isset(const struct GNUNET_NETWORK_FDSet *fds, |
229 | const struct GNUNET_NETWORK_Handle *desc); | 236 | const struct GNUNET_NETWORK_Handle *desc); |
230 | 237 | ||
231 | /** | 238 | /** |
232 | * Add one fd set to another | 239 | * Add one fd set to another |
@@ -234,7 +241,7 @@ int GNUNET_NETWORK_fdset_isset(const struct GNUNET_NETWORK_FDSet *fds, | |||
234 | * @param src the fd set to add from | 241 | * @param src the fd set to add from |
235 | */ | 242 | */ |
236 | void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, | 243 | void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, |
237 | const struct GNUNET_NETWORK_FDSet *src); | 244 | const struct GNUNET_NETWORK_FDSet *src); |
238 | 245 | ||
239 | /** | 246 | /** |
240 | * Copy one fd set to another | 247 | * Copy one fd set to another |
@@ -242,7 +249,7 @@ void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, | |||
242 | * @param from source | 249 | * @param from source |
243 | */ | 250 | */ |
244 | void GNUNET_NETWORK_fdset_copy(struct GNUNET_NETWORK_FDSet *to, | 251 | void GNUNET_NETWORK_fdset_copy(struct GNUNET_NETWORK_FDSet *to, |
245 | const struct GNUNET_NETWORK_FDSet *from); | 252 | const struct GNUNET_NETWORK_FDSet *from); |
246 | 253 | ||
247 | /** | 254 | /** |
248 | * Copy a native fd set | 255 | * Copy a native fd set |
@@ -250,8 +257,9 @@ void GNUNET_NETWORK_fdset_copy(struct GNUNET_NETWORK_FDSet *to, | |||
250 | * @param from native source set | 257 | * @param from native source set |
251 | * @param the biggest socket number in from + 1 | 258 | * @param the biggest socket number in from + 1 |
252 | */ | 259 | */ |
253 | void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, const fd_set *from, | 260 | void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, |
254 | int nfds); | 261 | const fd_set *from, |
262 | int nfds); | ||
255 | 263 | ||
256 | /** | 264 | /** |
257 | * Add a file handle to the fd set | 265 | * Add a file handle to the fd set |
@@ -259,7 +267,7 @@ void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, const fd | |||
259 | * @param h the file handle to add | 267 | * @param h the file handle to add |
260 | */ | 268 | */ |
261 | void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, | 269 | void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, |
262 | const struct GNUNET_DISK_FileHandle *h); | 270 | const struct GNUNET_DISK_FileHandle *h); |
263 | 271 | ||
264 | /** | 272 | /** |
265 | * Check if a file handle is part of an fd set | 273 | * Check if a file handle is part of an fd set |
@@ -268,7 +276,7 @@ void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, | |||
268 | * @return GNUNET_YES if the file handle is part of the set | 276 | * @return GNUNET_YES if the file handle is part of the set |
269 | */ | 277 | */ |
270 | int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, | 278 | int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, |
271 | const struct GNUNET_DISK_FileHandle *h); | 279 | const struct GNUNET_DISK_FileHandle *h); |
272 | 280 | ||
273 | /** | 281 | /** |
274 | * Checks if two fd sets overlap | 282 | * Checks if two fd sets overlap |
@@ -276,7 +284,8 @@ int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, | |||
276 | * @param fds2 second fd set | 284 | * @param fds2 second fd set |
277 | * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise | 285 | * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise |
278 | */ | 286 | */ |
279 | int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, const struct GNUNET_NETWORK_FDSet *fds2); | 287 | int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, |
288 | const struct GNUNET_NETWORK_FDSet *fds2); | ||
280 | 289 | ||
281 | /** | 290 | /** |
282 | * Creates an fd set | 291 | * Creates an fd set |
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 3af4f72a3..3bc6eb5f9 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h | |||
@@ -50,11 +50,36 @@ extern "C" | |||
50 | */ | 50 | */ |
51 | enum GNUNET_OS_InstallationPathKind | 51 | enum GNUNET_OS_InstallationPathKind |
52 | { | 52 | { |
53 | /** | ||
54 | * Return the "PREFIX" directory given to configure. | ||
55 | */ | ||
53 | GNUNET_OS_IPK_PREFIX, | 56 | GNUNET_OS_IPK_PREFIX, |
57 | |||
58 | /** | ||
59 | * Return the directory where the program binaries are installed. (bin/) | ||
60 | */ | ||
54 | GNUNET_OS_IPK_BINDIR, | 61 | GNUNET_OS_IPK_BINDIR, |
62 | |||
63 | /** | ||
64 | * Return the directory where libraries are installed. (lib/) | ||
65 | */ | ||
55 | GNUNET_OS_IPK_LIBDIR, | 66 | GNUNET_OS_IPK_LIBDIR, |
67 | |||
68 | /** | ||
69 | * Return the directory where data is installed (share/) | ||
70 | */ | ||
56 | GNUNET_OS_IPK_DATADIR, | 71 | GNUNET_OS_IPK_DATADIR, |
72 | |||
73 | /** | ||
74 | * Return the directory where translations are installed (share/locale/) | ||
75 | */ | ||
57 | GNUNET_OS_IPK_LOCALEDIR, | 76 | GNUNET_OS_IPK_LOCALEDIR, |
77 | |||
78 | /** | ||
79 | * Return the installation directory of this application, not | ||
80 | * the one of the overall GNUnet installation (in case they | ||
81 | * are different). | ||
82 | */ | ||
58 | GNUNET_OS_IPK_SELF_PREFIX | 83 | GNUNET_OS_IPK_SELF_PREFIX |
59 | }; | 84 | }; |
60 | 85 | ||
@@ -64,10 +89,30 @@ enum GNUNET_OS_InstallationPathKind | |||
64 | */ | 89 | */ |
65 | enum GNUNET_OS_ProcessStatusType | 90 | enum GNUNET_OS_ProcessStatusType |
66 | { | 91 | { |
92 | /** | ||
93 | * The process is not known to the OS (or at | ||
94 | * least not one of our children). | ||
95 | */ | ||
67 | GNUNET_OS_PROCESS_UNKNOWN, | 96 | GNUNET_OS_PROCESS_UNKNOWN, |
97 | |||
98 | /** | ||
99 | * The process is still running. | ||
100 | */ | ||
68 | GNUNET_OS_PROCESS_RUNNING, | 101 | GNUNET_OS_PROCESS_RUNNING, |
102 | |||
103 | /** | ||
104 | * The process is paused (but could be resumed). | ||
105 | */ | ||
69 | GNUNET_OS_PROCESS_STOPPED, | 106 | GNUNET_OS_PROCESS_STOPPED, |
107 | |||
108 | /** | ||
109 | * The process exited with a return code. | ||
110 | */ | ||
70 | GNUNET_OS_PROCESS_EXITED, | 111 | GNUNET_OS_PROCESS_EXITED, |
112 | |||
113 | /** | ||
114 | * The process was killed by a signal. | ||
115 | */ | ||
71 | GNUNET_OS_PROCESS_SIGNALED | 116 | GNUNET_OS_PROCESS_SIGNALED |
72 | }; | 117 | }; |
73 | 118 | ||
@@ -103,10 +148,11 @@ typedef int (*GNUNET_OS_NetworkInterfaceProcessor) (void *cls, | |||
103 | 148 | ||
104 | /** | 149 | /** |
105 | * @brief Enumerate all network interfaces | 150 | * @brief Enumerate all network interfaces |
106 | * @param callback the callback function | 151 | * @param proc the callback function |
152 | * @param proc_cls closure for proc | ||
107 | */ | 153 | */ |
108 | void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor | 154 | void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor |
109 | proc, void *cls); | 155 | proc, void *proc_cls); |
110 | 156 | ||
111 | /** | 157 | /** |
112 | * Get the current CPU load. | 158 | * Get the current CPU load. |
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h index e4f603c4e..b8c7b99fe 100644 --- a/src/include/gnunet_plugin_lib.h +++ b/src/include/gnunet_plugin_lib.h | |||
@@ -41,6 +41,11 @@ extern "C" | |||
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Signature of any function exported by a plugin. | 43 | * Signature of any function exported by a plugin. |
44 | * | ||
45 | * @param arg argument to the function (context) | ||
46 | * @return some pointer, NULL if the plugin was | ||
47 | * shutdown or if there was an error, otherwise | ||
48 | * the plugin's API on success | ||
44 | */ | 49 | */ |
45 | typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); | 50 | typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); |
46 | 51 | ||
@@ -55,7 +60,7 @@ typedef void *(*GNUNET_PLUGIN_Callback) (void *arg); | |||
55 | * | 60 | * |
56 | * @param library_name name of the plugin to load | 61 | * @param library_name name of the plugin to load |
57 | * @param arg argument to the plugin initialization function | 62 | * @param arg argument to the plugin initialization function |
58 | * @return whatever the initialization function returned | 63 | * @return whatever the initialization function returned, NULL on error |
59 | */ | 64 | */ |
60 | void *GNUNET_PLUGIN_load (const char *library_name, void *arg); | 65 | void *GNUNET_PLUGIN_load (const char *library_name, void *arg); |
61 | 66 | ||
@@ -66,7 +71,8 @@ void *GNUNET_PLUGIN_load (const char *library_name, void *arg); | |||
66 | * | 71 | * |
67 | * @param library_name name of the plugin to unload | 72 | * @param library_name name of the plugin to unload |
68 | * @param arg argument to the plugin shutdown function | 73 | * @param arg argument to the plugin shutdown function |
69 | * @return whatever the shutdown function returned | 74 | * @return whatever the shutdown function returned, typically NULL |
75 | * or a "char *" representing the error message | ||
70 | */ | 76 | */ |
71 | void *GNUNET_PLUGIN_unload (const char *library_name, void *arg); | 77 | void *GNUNET_PLUGIN_unload (const char *library_name, void *arg); |
72 | 78 | ||
diff --git a/src/include/gnunet_signal_lib.h b/src/include/gnunet_signal_lib.h index af1ec0de4..e386ccc0e 100644 --- a/src/include/gnunet_signal_lib.h +++ b/src/include/gnunet_signal_lib.h | |||
@@ -35,6 +35,10 @@ extern "C" | |||
35 | #endif | 35 | #endif |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | /** | ||
39 | * Context created when a signal handler is installed; | ||
40 | * can be used to restore it to the previous state later. | ||
41 | */ | ||
38 | struct GNUNET_SIGNAL_Context; | 42 | struct GNUNET_SIGNAL_Context; |
39 | 43 | ||
40 | /** | 44 | /** |
@@ -50,6 +54,10 @@ typedef void (*GNUNET_SIGNAL_Handler) (void); | |||
50 | /** | 54 | /** |
51 | * Install a signal handler that will be run if the | 55 | * Install a signal handler that will be run if the |
52 | * given signal is received. | 56 | * given signal is received. |
57 | * | ||
58 | * @param signal the number of the signal | ||
59 | * @param handler the function to call | ||
60 | * @return context that can be used to restore, NULL on error | ||
53 | */ | 61 | */ |
54 | struct GNUNET_SIGNAL_Context *GNUNET_SIGNAL_handler_install (int signal, | 62 | struct GNUNET_SIGNAL_Context *GNUNET_SIGNAL_handler_install (int signal, |
55 | GNUNET_SIGNAL_Handler | 63 | GNUNET_SIGNAL_Handler |
@@ -57,6 +65,9 @@ struct GNUNET_SIGNAL_Context *GNUNET_SIGNAL_handler_install (int signal, | |||
57 | 65 | ||
58 | /** | 66 | /** |
59 | * Uninstall a previously installed signal hander. | 67 | * Uninstall a previously installed signal hander. |
68 | * | ||
69 | * @param ctx context that was returned when the | ||
70 | * signal handler was installed | ||
60 | */ | 71 | */ |
61 | void GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx); | 72 | void GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx); |
62 | 73 | ||
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index ab0f1ad7c..a466074a3 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -52,25 +52,33 @@ extern "C" | |||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Convert a given filesize into a fancy human-readable format. | 54 | * Convert a given filesize into a fancy human-readable format. |
55 | * | ||
56 | * @param size number of bytes | ||
57 | * @return fancy representation of the size (possibly rounded) for humans | ||
55 | */ | 58 | */ |
56 | char *GNUNET_STRINGS_byte_size_fancy (unsigned long long size); | 59 | char *GNUNET_STRINGS_byte_size_fancy (unsigned long long size); |
57 | 60 | ||
61 | |||
58 | /** | 62 | /** |
59 | * Convert the len characters long character sequence | 63 | * Convert the len characters long character sequence |
60 | * given in input that is in the given charset | 64 | * given in input that is in the given charset |
61 | * to UTF-8. | 65 | * to UTF-8. |
62 | * | 66 | * |
67 | * @param input the input string (not necessarily 0-terminated) | ||
68 | * @param len the number of bytes in the input | ||
69 | * @param charset character set to convert from | ||
63 | * @return the converted string (0-terminated) | 70 | * @return the converted string (0-terminated) |
64 | */ | 71 | */ |
65 | char *GNUNET_STRINGS_to_utf8 (const char *input, | 72 | char *GNUNET_STRINGS_to_utf8 (const char *input, |
66 | size_t len, const char *charset); | 73 | size_t len, const char *charset); |
67 | 74 | ||
75 | |||
68 | /** | 76 | /** |
69 | * Complete filename (a la shell) from abbrevition. | 77 | * Complete filename (a la shell) from abbrevition. |
70 | * | 78 | * |
71 | * @param fil the name of the file, may contain ~/ or | 79 | * @param fil the name of the file, may contain ~/ or |
72 | * be relative to the current directory | 80 | * be relative to the current directory |
73 | * @returns the full file name, | 81 | * @return the full file name, |
74 | * NULL is returned on error | 82 | * NULL is returned on error |
75 | */ | 83 | */ |
76 | char *GNUNET_STRINGS_filename_expand (const char *fil); | 84 | char *GNUNET_STRINGS_filename_expand (const char *fil); |
@@ -87,12 +95,19 @@ char *GNUNET_STRINGS_filename_expand (const char *fil); | |||
87 | * used to parse the buffer back into individual | 95 | * used to parse the buffer back into individual |
88 | * strings. | 96 | * strings. |
89 | * | 97 | * |
98 | * @param buffer the buffer to fill with strings, can | ||
99 | * be NULL in which case only the necessary | ||
100 | * amount of space will be calculated | ||
101 | * @param size number of bytes available in buffer | ||
102 | * @param count number of strings that follow | ||
103 | * @param ... count 0-terminated strings to copy to buffer | ||
90 | * @return number of bytes written to the buffer | 104 | * @return number of bytes written to the buffer |
91 | * (or number of bytes that would have been written) | 105 | * (or number of bytes that would have been written) |
92 | */ | 106 | */ |
93 | unsigned int GNUNET_STRINGS_buffer_fill (char *buffer, | 107 | size_t GNUNET_STRINGS_buffer_fill (char *buffer, |
94 | unsigned int size, | 108 | size_t size, |
95 | unsigned int count, ...); | 109 | unsigned int count, ...); |
110 | |||
96 | 111 | ||
97 | /** | 112 | /** |
98 | * Given a buffer of a given size, find "count" | 113 | * Given a buffer of a given size, find "count" |
@@ -104,11 +119,12 @@ unsigned int GNUNET_STRINGS_buffer_fill (char *buffer, | |||
104 | * @param buffer the buffer to parse | 119 | * @param buffer the buffer to parse |
105 | * @param size size of the buffer | 120 | * @param size size of the buffer |
106 | * @param count number of strings to locate | 121 | * @param count number of strings to locate |
122 | * @param ... pointers to where to store the strings | ||
107 | * @return offset of the character after the last 0-termination | 123 | * @return offset of the character after the last 0-termination |
108 | * in the buffer, or 0 on error. | 124 | * in the buffer, or 0 on error. |
109 | */ | 125 | */ |
110 | unsigned int GNUNET_STRINGS_buffer_tokenize (const char *buffer, | 126 | unsigned int GNUNET_STRINGS_buffer_tokenize (const char *buffer, |
111 | unsigned int size, | 127 | size_t size, |
112 | unsigned int count, ...); | 128 | unsigned int count, ...); |
113 | 129 | ||
114 | 130 | ||
@@ -131,6 +147,7 @@ char *GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t); | |||
131 | */ | 147 | */ |
132 | char *GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative | 148 | char *GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative |
133 | delta); | 149 | delta); |
150 | |||
134 | #if 0 /* keep Emacsens' auto-indent happy */ | 151 | #if 0 /* keep Emacsens' auto-indent happy */ |
135 | { | 152 | { |
136 | #endif | 153 | #endif |
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index e4b9dd970..3b901f526 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -43,6 +43,9 @@ extern "C" | |||
43 | */ | 43 | */ |
44 | struct GNUNET_TIME_Absolute | 44 | struct GNUNET_TIME_Absolute |
45 | { | 45 | { |
46 | /** | ||
47 | * The actual value. | ||
48 | */ | ||
46 | uint64_t value; | 49 | uint64_t value; |
47 | }; | 50 | }; |
48 | 51 | ||
@@ -52,6 +55,9 @@ struct GNUNET_TIME_Absolute | |||
52 | */ | 55 | */ |
53 | struct GNUNET_TIME_Relative | 56 | struct GNUNET_TIME_Relative |
54 | { | 57 | { |
58 | /** | ||
59 | * The actual value. | ||
60 | */ | ||
55 | uint64_t value; | 61 | uint64_t value; |
56 | }; | 62 | }; |
57 | 63 | ||
@@ -61,6 +67,9 @@ struct GNUNET_TIME_Relative | |||
61 | */ | 67 | */ |
62 | struct GNUNET_TIME_RelativeNBO | 68 | struct GNUNET_TIME_RelativeNBO |
63 | { | 69 | { |
70 | /** | ||
71 | * The actual value (in network byte order). | ||
72 | */ | ||
64 | uint64_t value__ GNUNET_PACKED; | 73 | uint64_t value__ GNUNET_PACKED; |
65 | }; | 74 | }; |
66 | 75 | ||
@@ -70,22 +79,61 @@ struct GNUNET_TIME_RelativeNBO | |||
70 | */ | 79 | */ |
71 | struct GNUNET_TIME_AbsoluteNBO | 80 | struct GNUNET_TIME_AbsoluteNBO |
72 | { | 81 | { |
82 | /** | ||
83 | * The actual value (in network byte order). | ||
84 | */ | ||
73 | uint64_t value__ GNUNET_PACKED; | 85 | uint64_t value__ GNUNET_PACKED; |
74 | }; | 86 | }; |
75 | 87 | ||
76 | 88 | ||
77 | /** | 89 | /** |
78 | * @brief constants to specify time | 90 | * Relative time zero. |
79 | */ | 91 | */ |
80 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() | 92 | #define GNUNET_TIME_UNIT_ZERO GNUNET_TIME_relative_get_zero() |
93 | |||
94 | /** | ||
95 | * Absolute time zero. | ||
96 | */ | ||
81 | #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() | 97 | #define GNUNET_TIME_UNIT_ZERO_ABS GNUNET_TIME_absolute_get_zero() |
98 | |||
99 | /** | ||
100 | * One millisecond, our basic time unit. | ||
101 | */ | ||
82 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() | 102 | #define GNUNET_TIME_UNIT_MILLISECONDS GNUNET_TIME_relative_get_unit() |
103 | |||
104 | /** | ||
105 | * One second. | ||
106 | */ | ||
83 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) | 107 | #define GNUNET_TIME_UNIT_SECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) |
108 | |||
109 | /** | ||
110 | * One minute. | ||
111 | */ | ||
84 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) | 112 | #define GNUNET_TIME_UNIT_MINUTES GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) |
113 | |||
114 | /** | ||
115 | * One hour. | ||
116 | */ | ||
85 | #define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60) | 117 | #define GNUNET_TIME_UNIT_HOURS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 60) |
118 | |||
119 | /** | ||
120 | * One day. | ||
121 | */ | ||
86 | #define GNUNET_TIME_UNIT_DAYS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 24) | 122 | #define GNUNET_TIME_UNIT_DAYS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_HOURS, 24) |
123 | |||
124 | /** | ||
125 | * One week. | ||
126 | */ | ||
87 | #define GNUNET_TIME_UNIT_WEEKS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 7) | 127 | #define GNUNET_TIME_UNIT_WEEKS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 7) |
128 | |||
129 | /** | ||
130 | * One month (30 days). | ||
131 | */ | ||
88 | #define GNUNET_TIME_UNIT_MONTHS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 30) | 132 | #define GNUNET_TIME_UNIT_MONTHS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 30) |
133 | |||
134 | /** | ||
135 | * One year (365 days). | ||
136 | */ | ||
89 | #define GNUNET_TIME_UNIT_YEARS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 365) | 137 | #define GNUNET_TIME_UNIT_YEARS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_DAYS, 365) |
90 | 138 | ||
91 | /** | 139 | /** |
@@ -136,6 +184,7 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get (void); | |||
136 | * Convert relative time to an absolute time in the | 184 | * Convert relative time to an absolute time in the |
137 | * future. | 185 | * future. |
138 | * | 186 | * |
187 | * @param rel relative time to convert | ||
139 | * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) | 188 | * @return timestamp that is "rel" in the future, or FOREVER if rel==FOREVER (or if we would overflow) |
140 | */ | 189 | */ |
141 | struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct | 190 | struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct |
@@ -145,6 +194,8 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute (struct | |||
145 | /** | 194 | /** |
146 | * Return the minimum of two relative time values. | 195 | * Return the minimum of two relative time values. |
147 | * | 196 | * |
197 | * @param t1 first timestamp | ||
198 | * @param t2 other timestamp | ||
148 | * @return timestamp that is smaller | 199 | * @return timestamp that is smaller |
149 | */ | 200 | */ |
150 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct | 201 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct |
@@ -157,6 +208,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_min (struct | |||
157 | * Given a timestamp in the future, how much time | 208 | * Given a timestamp in the future, how much time |
158 | * remains until then? | 209 | * remains until then? |
159 | * | 210 | * |
211 | * @param future some absolute time, typically in the future | ||
160 | * @return future - now, or 0 if now >= future, or FOREVER if future==FOREVER. | 212 | * @return future - now, or 0 if now >= future, or FOREVER if future==FOREVER. |
161 | */ | 213 | */ |
162 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining (struct | 214 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining (struct |
@@ -184,6 +236,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolu | |||
184 | * Use this function instead of actual subtraction to ensure that | 236 | * Use this function instead of actual subtraction to ensure that |
185 | * "FOREVER" and overflows are handeled correctly. | 237 | * "FOREVER" and overflows are handeled correctly. |
186 | * | 238 | * |
239 | * @param start some absolute time | ||
240 | * @param end some absolute time (typically larger or equal to start) | ||
187 | * @return 0 if start >= end; FOREVER if end==FOREVER; otherwise end - start | 241 | * @return 0 if start >= end; FOREVER if end==FOREVER; otherwise end - start |
188 | */ | 242 | */ |
189 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct | 243 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct |
@@ -197,6 +251,7 @@ struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference (struct | |||
197 | * Get the duration of an operation as the | 251 | * Get the duration of an operation as the |
198 | * difference of the current time and the given start time "hence". | 252 | * difference of the current time and the given start time "hence". |
199 | * | 253 | * |
254 | * @param hence some absolute time, typically in the past | ||
200 | * @return aborts if hence==FOREVER, 0 if hence > now, otherwise now-hence. | 255 | * @return aborts if hence==FOREVER, 0 if hence > now, otherwise now-hence. |
201 | */ | 256 | */ |
202 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct | 257 | struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct |
@@ -208,6 +263,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration (struct | |||
208 | * Add a given relative duration to the | 263 | * Add a given relative duration to the |
209 | * given start time. | 264 | * given start time. |
210 | * | 265 | * |
266 | * @param start some absolute time | ||
267 | * @param duration some relative time to add | ||
211 | * @return FOREVER if either argument is FOREVER or on overflow; start+duration otherwise | 268 | * @return FOREVER if either argument is FOREVER or on overflow; start+duration otherwise |
212 | */ | 269 | */ |
213 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct | 270 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct |
@@ -220,6 +277,8 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add (struct | |||
220 | /** | 277 | /** |
221 | * Multiply relative time by a given factor. | 278 | * Multiply relative time by a given factor. |
222 | * | 279 | * |
280 | * @param rel some duration | ||
281 | * @param factor integer to multiply with | ||
223 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor | 282 | * @return FOREVER if rel=FOREVER or on overflow; otherwise rel*factor |
224 | */ | 283 | */ |
225 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct | 284 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct |
@@ -231,6 +290,8 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply (struct | |||
231 | /** | 290 | /** |
232 | * Add relative times together. | 291 | * Add relative times together. |
233 | * | 292 | * |
293 | * @param a1 some relative time | ||
294 | * @param a2 some other relative time | ||
234 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise | 295 | * @return FOREVER if either argument is FOREVER or on overflow; a1+a2 otherwise |
235 | */ | 296 | */ |
236 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct | 297 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct |
@@ -242,6 +303,9 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_add (struct | |||
242 | 303 | ||
243 | /** | 304 | /** |
244 | * Convert relative time to network byte order. | 305 | * Convert relative time to network byte order. |
306 | * | ||
307 | * @param a time to convert | ||
308 | * @return converted time value | ||
245 | */ | 309 | */ |
246 | struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct | 310 | struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct |
247 | GNUNET_TIME_Relative | 311 | GNUNET_TIME_Relative |
@@ -249,6 +313,9 @@ struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton (struct | |||
249 | 313 | ||
250 | /** | 314 | /** |
251 | * Convert relative time from network byte order. | 315 | * Convert relative time from network byte order. |
316 | * | ||
317 | * @param a time to convert | ||
318 | * @return converted time value | ||
252 | */ | 319 | */ |
253 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct | 320 | struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct |
254 | GNUNET_TIME_RelativeNBO | 321 | GNUNET_TIME_RelativeNBO |
@@ -256,6 +323,9 @@ struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh (struct | |||
256 | 323 | ||
257 | /** | 324 | /** |
258 | * Convert relative time to network byte order. | 325 | * Convert relative time to network byte order. |
326 | * | ||
327 | * @param a time to convert | ||
328 | * @return converted time value | ||
259 | */ | 329 | */ |
260 | struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct | 330 | struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct |
261 | GNUNET_TIME_Absolute | 331 | GNUNET_TIME_Absolute |
@@ -263,6 +333,9 @@ struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton (struct | |||
263 | 333 | ||
264 | /** | 334 | /** |
265 | * Convert relative time from network byte order. | 335 | * Convert relative time from network byte order. |
336 | * | ||
337 | * @param a time to convert | ||
338 | * @return converted time value | ||
266 | */ | 339 | */ |
267 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct | 340 | struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct |
268 | GNUNET_TIME_AbsoluteNBO | 341 | GNUNET_TIME_AbsoluteNBO |
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index e4c3fe040..20dd10586 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -22,6 +22,9 @@ | |||
22 | * @file statistics/gnunet-service-statistics.c | 22 | * @file statistics/gnunet-service-statistics.c |
23 | * @brief program that tracks statistics | 23 | * @brief program that tracks statistics |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - use BIO for IO operations | ||
25 | */ | 28 | */ |
26 | #include "platform.h" | 29 | #include "platform.h" |
27 | #include "gnunet_disk_lib.h" | 30 | #include "gnunet_disk_lib.h" |
@@ -121,7 +124,7 @@ load (struct GNUNET_SERVER_Handle *server, | |||
121 | GNUNET_free (fn); | 124 | GNUNET_free (fn); |
122 | return; | 125 | return; |
123 | } | 126 | } |
124 | buf = GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_READ, sb.st_size); | 127 | buf = GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_TYPE_READ, sb.st_size); |
125 | if (NULL == buf) | 128 | if (NULL == buf) |
126 | { | 129 | { |
127 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "mmap", fn); | 130 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "mmap", fn); |
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 749f824cd..2f78c98f6 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -171,6 +171,14 @@ GNUNET_xgrow_ (void **old, | |||
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | /** | ||
175 | * Like asprintf, just portable. | ||
176 | * | ||
177 | * @param buf set to a buffer of sufficient size (allocated, caller must free) | ||
178 | * @param format format string (see printf, fprintf, etc.) | ||
179 | * @param ... data for format string | ||
180 | * @return number of bytes in "*buf" excluding 0-termination | ||
181 | */ | ||
174 | int | 182 | int |
175 | GNUNET_asprintf (char **buf, const char *format, ...) | 183 | GNUNET_asprintf (char **buf, const char *format, ...) |
176 | { | 184 | { |
@@ -187,6 +195,16 @@ GNUNET_asprintf (char **buf, const char *format, ...) | |||
187 | return ret; | 195 | return ret; |
188 | } | 196 | } |
189 | 197 | ||
198 | |||
199 | /** | ||
200 | * Like snprintf, just aborts if the buffer is of insufficient size. | ||
201 | * | ||
202 | * @param buf pointer to buffer that is written to | ||
203 | * @param size number of bytes in buf | ||
204 | * @param format format strings | ||
205 | * @param ... data for format string | ||
206 | * @return number of bytes written to buf or negative value on error | ||
207 | */ | ||
190 | int | 208 | int |
191 | GNUNET_snprintf (char *buf, size_t size, const char *format, ...) | 209 | GNUNET_snprintf (char *buf, size_t size, const char *format, ...) |
192 | { | 210 | { |
diff --git a/src/util/disk.c b/src/util/disk.c index 0aeab5b8b..9f2f8dcf7 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -1012,9 +1012,9 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) | |||
1012 | /** | 1012 | /** |
1013 | * Lock a part of a file | 1013 | * Lock a part of a file |
1014 | * @param fh file handle | 1014 | * @param fh file handle |
1015 | * @lockStart absolute position from where to lock | 1015 | * @param lockStart absolute position from where to lock |
1016 | * @lockEnd absolute position until where to lock | 1016 | * @param lockEnd absolute position until where to lock |
1017 | * @excl GNUNET_YES for an exclusive lock | 1017 | * @param excl GNUNET_YES for an exclusive lock |
1018 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1018 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1019 | */ | 1019 | */ |
1020 | int | 1020 | int |
@@ -1058,8 +1058,8 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | |||
1058 | /** | 1058 | /** |
1059 | * Unlock a part of a file | 1059 | * Unlock a part of a file |
1060 | * @param fh file handle | 1060 | * @param fh file handle |
1061 | * @lockStart absolute position from where to unlock | 1061 | * @param lockStart absolute position from where to unlock |
1062 | * @lockEnd absolute position until where to unlock | 1062 | * @param lockEnd absolute position until where to unlock |
1063 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1063 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
1064 | */ | 1064 | */ |
1065 | int | 1065 | int |
@@ -1103,11 +1103,13 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, | |||
1103 | * Open a file | 1103 | * Open a file |
1104 | * @param fn file name to be opened | 1104 | * @param fn file name to be opened |
1105 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags | 1105 | * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags |
1106 | * @param perm permissions for the newly created file | 1106 | * @param ... permissions for the newly created file |
1107 | * @return IO handle on success, NULL on error | 1107 | * @return IO handle on success, NULL on error |
1108 | */ | 1108 | */ |
1109 | struct GNUNET_DISK_FileHandle * | 1109 | struct GNUNET_DISK_FileHandle * |
1110 | GNUNET_DISK_file_open (const char *fn, int flags, ...) | 1110 | GNUNET_DISK_file_open (const char *fn, |
1111 | enum GNUNET_DISK_OpenFlags flags, | ||
1112 | ...) | ||
1111 | { | 1113 | { |
1112 | char *expfn; | 1114 | char *expfn; |
1113 | struct GNUNET_DISK_FileHandle *ret; | 1115 | struct GNUNET_DISK_FileHandle *ret; |
@@ -1363,13 +1365,13 @@ struct GNUNET_DISK_MapHandle | |||
1363 | * Map a file into memory | 1365 | * Map a file into memory |
1364 | * @param h open file handle | 1366 | * @param h open file handle |
1365 | * @param m handle to the new mapping | 1367 | * @param m handle to the new mapping |
1366 | * @param access access specification, GNUNET_DISK_MAP_xxx | 1368 | * @param access access specification, GNUNET_DISK_MAP_TYPE_xxx |
1367 | * @param len size of the mapping | 1369 | * @param len size of the mapping |
1368 | * @return pointer to the mapped memory region, NULL on failure | 1370 | * @return pointer to the mapped memory region, NULL on failure |
1369 | */ | 1371 | */ |
1370 | void * | 1372 | void * |
1371 | GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, | 1373 | GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, |
1372 | int access, size_t len) | 1374 | enum GNUNET_DISK_MapType access, size_t len) |
1373 | { | 1375 | { |
1374 | if (h == NULL) | 1376 | if (h == NULL) |
1375 | { | 1377 | { |
@@ -1381,17 +1383,18 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK | |||
1381 | DWORD mapAccess, protect; | 1383 | DWORD mapAccess, protect; |
1382 | void *ret; | 1384 | void *ret; |
1383 | 1385 | ||
1384 | if (access & GNUNET_DISK_MAP_READ && access & GNUNET_DISK_MAP_WRITE) | 1386 | if ((access & GNUNET_DISK_MAP_TYPE_READ) && |
1387 | (access & GNUNET_DISK_MAP_TYPE_WRITE)) | ||
1385 | { | 1388 | { |
1386 | protect = PAGE_READWRITE; | 1389 | protect = PAGE_READWRITE; |
1387 | mapAccess = FILE_MAP_ALL_ACCESS; | 1390 | mapAccess = FILE_MAP_ALL_ACCESS; |
1388 | } | 1391 | } |
1389 | else if (access & GNUNET_DISK_MAP_READ) | 1392 | else if (access & GNUNET_DISK_MAP_TYPE_READ) |
1390 | { | 1393 | { |
1391 | protect = PAGE_READONLY; | 1394 | protect = PAGE_READONLY; |
1392 | mapAccess = FILE_MAP_READ; | 1395 | mapAccess = FILE_MAP_READ; |
1393 | } | 1396 | } |
1394 | else if (access & GNUNET_DISK_MAP_WRITE) | 1397 | else if (access & GNUNET_DISK_MAP_TYPE_WRITE) |
1395 | { | 1398 | { |
1396 | protect = PAGE_READWRITE; | 1399 | protect = PAGE_READWRITE; |
1397 | mapAccess = FILE_MAP_WRITE; | 1400 | mapAccess = FILE_MAP_WRITE; |
@@ -1424,9 +1427,9 @@ GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK | |||
1424 | int prot; | 1427 | int prot; |
1425 | 1428 | ||
1426 | prot = 0; | 1429 | prot = 0; |
1427 | if (access & GNUNET_DISK_MAP_READ) | 1430 | if (access & GNUNET_DISK_MAP_TYPE_READ) |
1428 | prot = PROT_READ; | 1431 | prot = PROT_READ; |
1429 | if (access & GNUNET_DISK_MAP_WRITE) | 1432 | if (access & GNUNET_DISK_MAP_TYPE_WRITE) |
1430 | prot |= PROT_WRITE; | 1433 | prot |= PROT_WRITE; |
1431 | *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle)); | 1434 | *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle)); |
1432 | (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, h->fd, 0); | 1435 | (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, h->fd, 0); |
diff --git a/src/util/strings.c b/src/util/strings.c index be0e6c1f0..13c0b6a58 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -45,12 +45,18 @@ | |||
45 | * used to parse the buffer back into individual | 45 | * used to parse the buffer back into individual |
46 | * strings. | 46 | * strings. |
47 | * | 47 | * |
48 | * @param buffer the buffer to fill with strings, can | ||
49 | * be NULL in which case only the necessary | ||
50 | * amount of space will be calculated | ||
51 | * @param size number of bytes available in buffer | ||
52 | * @param count number of strings that follow | ||
53 | * @param ... count 0-terminated strings to copy to buffer | ||
48 | * @return number of bytes written to the buffer | 54 | * @return number of bytes written to the buffer |
49 | * (or number of bytes that would have been written) | 55 | * (or number of bytes that would have been written) |
50 | */ | 56 | */ |
51 | unsigned int | 57 | unsigned int |
52 | GNUNET_STRINGS_buffer_fill (char *buffer, | 58 | GNUNET_STRINGS_buffer_fill (char *buffer, |
53 | unsigned int size, unsigned int count, ...) | 59 | size_t size, unsigned int count, ...) |
54 | { | 60 | { |
55 | unsigned int needed; | 61 | unsigned int needed; |
56 | unsigned int slen; | 62 | unsigned int slen; |
@@ -91,7 +97,7 @@ GNUNET_STRINGS_buffer_fill (char *buffer, | |||
91 | */ | 97 | */ |
92 | unsigned int | 98 | unsigned int |
93 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, | 99 | GNUNET_STRINGS_buffer_tokenize (const char *buffer, |
94 | unsigned int size, unsigned int count, ...) | 100 | size_t size, unsigned int count, ...) |
95 | { | 101 | { |
96 | unsigned int start; | 102 | unsigned int start; |
97 | unsigned int needed; | 103 | unsigned int needed; |
@@ -122,6 +128,9 @@ GNUNET_STRINGS_buffer_tokenize (const char *buffer, | |||
122 | 128 | ||
123 | /** | 129 | /** |
124 | * Convert a given filesize into a fancy human-readable format. | 130 | * Convert a given filesize into a fancy human-readable format. |
131 | * | ||
132 | * @param size number of bytes | ||
133 | * @return fancy representation of the size (possibly rounded) for humans | ||
125 | */ | 134 | */ |
126 | char * | 135 | char * |
127 | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) | 136 | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) |