From ab3a3be75688c71b23570406816dbd12c67529ec Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 29 Aug 2009 19:46:39 +0000 Subject: [PATCH] more fixes --- src/include/gnunet_container_lib.h | 15 ++++++----- src/include/gnunet_disk_lib.h | 20 +++++++++----- src/include/gnunet_network_lib.h | 13 +++++---- src/include/gnunet_scheduler_lib.h | 6 ++--- src/util/container_bloomfilter.c | 34 +++++++++++++----------- src/util/{network_socket.c => network.c} | 0 6 files changed, 52 insertions(+), 36 deletions(-) rename src/util/{network_socket.c => network.c} (100%) diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 1adae17b1..087324174 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h @@ -52,10 +52,13 @@ struct GNUNET_CONTAINER_BloomFilter; /** * Iterator over HashCodes. * + * @param cls closure + * @param next set to the next hash code * @return GNUNET_YES if next was updated * GNUNET_NO if there are no more entries */ -typedef int (*GNUNET_HashCodeIterator) (GNUNET_HashCode * next, void *arg); +typedef int (*GNUNET_HashCodeIterator) (void *cls, + GNUNET_HashCode * next); /** * Load a bloom-filter from a file. @@ -170,14 +173,14 @@ int GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, * * @param bf the filter * @param iterator an iterator over all elements stored in the BF - * @param iterator_arg argument to the iterator function + * @param iterator_cls closure for iterator * @param size the new size for the filter * @param k the new number of GNUNET_CRYPTO_hash-function to apply per element */ void GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_HashCodeIterator iterator, - void *iterator_arg, + void *iterator_cls, unsigned int size, unsigned int k); /* ****************** metadata ******************* */ @@ -276,14 +279,14 @@ void GNUNET_CONTAINER_meta_data_add_publication_date (struct * Iterate over MD entries, excluding thumbnails. * * @param md metadata to inspect - * @param iterator function to call on each entry - * @param closure closure for iterator + * @param iter function to call on each entry + * @param iter_cls closure for iterator * @return number of entries */ int GNUNET_CONTAINER_meta_data_get_contents (const struct GNUNET_CONTAINER_MetaData *md, GNUNET_CONTAINER_MetaDataProcessor - iterator, void *closure); + iter, void *iter_cls); /** * Get the first MD entry of the given type. diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index f4fd6f36b..cb88fd3d0 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h @@ -22,18 +22,27 @@ * @file include/gnunet_disk_lib.h * @brief disk IO apis */ - #ifndef GNUNET_DISK_LIB_H #define GNUNET_DISK_LIB_H -#include "gnunet_configuration_lib.h" -#include "gnunet_scheduler_lib.h" +/** + * Opaque handle used to access files. + */ +struct GNUNET_DISK_FileHandle; + +/** + * Opaque handle used to manage a pipe. + */ +struct GNUNET_DISK_PipeHandle; + /* we need size_t, and since it can be both unsigned int or unsigned long long, this IS platform dependent; but "stdlib.h" should be portable 'enough' to be unconditionally available... */ #include +#include "gnunet_configuration_lib.h" +#include "gnunet_scheduler_lib.h" #ifdef __cplusplus extern "C" @@ -43,6 +52,7 @@ extern "C" #endif #endif + /* Open the file for reading */ #define GNUNET_DISK_OPEN_READ 1 /* Open the file for writing */ @@ -79,10 +89,6 @@ enum GNUNET_DISK_Seek GNUNET_DISK_SEEK_END }; -struct GNUNET_DISK_FileHandle; - -struct GNUNET_DISK_PipeHandle; - /** * Get the number of blocks that are left on the partition that * contains the given file (for normal users). diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 5828456ca..726114758 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h @@ -35,8 +35,6 @@ extern "C" #endif #endif -#include "gnunet_disk_lib.h" -#include "gnunet_time_lib.h" /** @@ -50,9 +48,14 @@ struct GNUNET_NETWORK_Descriptor; struct GNUNET_NETWORK_FDSet; -struct GNUNET_NETWORK_Descriptor *GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Descriptor *desc, - struct sockaddr *address, - socklen_t *address_len); +#include "gnunet_disk_lib.h" +#include "gnunet_time_lib.h" + + +struct GNUNET_NETWORK_Descriptor * +GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Descriptor *desc, + struct sockaddr *address, + socklen_t *address_len); int GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Descriptor diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 86f709ed6..0ace207ec 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h @@ -36,9 +36,6 @@ extern "C" #endif -#include "gnunet_time_lib.h" -#include "gnunet_network_lib.h" - /** * Opaque handle for the scheduling service. */ @@ -151,6 +148,9 @@ enum GNUNET_SCHEDULER_Priority GNUNET_SCHEDULER_PRIORITY_COUNT = 7 }; +#include "gnunet_time_lib.h" +#include "gnunet_network_lib.h" + /** * Context information passed to each scheduler task. diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index 9efc2647c..5cc947bd6 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c @@ -277,12 +277,13 @@ makeEmptyFile (const struct GNUNET_DISK_FileHandle *fh, unsigned int size) * bloomfilter iterator on each bit that is to be * set or tested for the key. * + * @param cls closure * @param bf the filter to manipulate * @param bit the current bit - * @param additional context specific argument */ -typedef void (*BitIterator) (struct GNUNET_CONTAINER_BloomFilter * bf, - unsigned int bit, void *arg); +typedef void (*BitIterator) (void *cls, + struct GNUNET_CONTAINER_BloomFilter * bf, + unsigned int bit); /** * Call an iterator for each bit that the bloomfilter @@ -309,9 +310,10 @@ iterateBits (struct GNUNET_CONTAINER_BloomFilter *bf, { while (slot < (sizeof (GNUNET_HashCode) / sizeof (unsigned int))) { - callback (bf, + callback (arg, + bf, (((unsigned int *) &tmp[round & 1])[slot]) & - ((bf->bitArraySize * 8) - 1), arg); + ((bf->bitArraySize * 8) - 1)); slot++; bitCount--; if (bitCount == 0) @@ -330,13 +332,14 @@ iterateBits (struct GNUNET_CONTAINER_BloomFilter *bf, /** * Callback: increment bit * + * @param cls not used * @param bf the filter to manipulate * @param bit the bit to increment - * @param arg not used */ static void -incrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, - unsigned int bit, void *arg) +incrementBitCallback (void *cls, + struct GNUNET_CONTAINER_BloomFilter *bf, + unsigned int bit) { incrementBit (bf->bitArray, bit, bf->fh); } @@ -344,13 +347,14 @@ incrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, /** * Callback: decrement bit * + * @param cls not used * @param bf the filter to manipulate * @param bit the bit to decrement - * @param arg not used */ static void -decrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, - unsigned int bit, void *arg) +decrementBitCallback (void *cls, + struct GNUNET_CONTAINER_BloomFilter *bf, + unsigned int bit) { decrementBit (bf->bitArray, bit, bf->fh); } @@ -358,13 +362,13 @@ decrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, /** * Callback: test if all bits are set * + * @param cls pointer set to GNUNET_NO if bit is not set * @param bf the filter * @param bit the bit to test - * @param arg pointer set to GNUNET_NO if bit is not set */ static void -testBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit, - void *cls) +testBitCallback (void *cls, + struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit) { int *arg = cls; if (GNUNET_NO == testBit (bf->bitArray, bit)) @@ -674,7 +678,7 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, memset (bf->bitArray, 0, bf->bitArraySize); if (bf->filename != NULL) makeEmptyFile (bf->fh, bf->bitArraySize * 4); - while (GNUNET_YES == iterator (&hc, iterator_arg)) + while (GNUNET_YES == iterator (iterator_arg, &hc)) GNUNET_CONTAINER_bloomfilter_add (bf, &hc); } diff --git a/src/util/network_socket.c b/src/util/network.c similarity index 100% rename from src/util/network_socket.c rename to src/util/network.c -- 2.25.1