aboutsummaryrefslogtreecommitdiff
path: root/src/block
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/block
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/block')
-rw-r--r--src/block/block.c25
-rw-r--r--src/block/plugin_block_dht.c24
-rw-r--r--src/block/plugin_block_dns.c3
-rw-r--r--src/block/plugin_block_fs.c48
-rw-r--r--src/block/plugin_block_test.c14
5 files changed, 56 insertions, 58 deletions
diff --git a/src/block/block.c b/src/block/block.c
index 582c13eb3..7c447f072 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -96,17 +96,14 @@ GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number,
96 * @param lib_ret the plugin API 96 * @param lib_ret the plugin API
97 */ 97 */
98static void 98static void
99add_plugin (void *cls, 99add_plugin (void *cls, const char *library_name, void *lib_ret)
100 const char *library_name,
101 void *lib_ret)
102{ 100{
103 struct GNUNET_BLOCK_Context *ctx = cls; 101 struct GNUNET_BLOCK_Context *ctx = cls;
104 struct GNUNET_BLOCK_PluginFunctions *api = lib_ret; 102 struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
105 struct Plugin *plugin; 103 struct Plugin *plugin;
106 104
107 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 105 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugin `%s'\n"),
108 _("Loading block plugin `%s'\n"), 106 library_name);
109 library_name);
110 plugin = GNUNET_malloc (sizeof (struct Plugin)); 107 plugin = GNUNET_malloc (sizeof (struct Plugin));
111 plugin->api = api; 108 plugin->api = api;
112 plugin->library_name = GNUNET_strdup (library_name); 109 plugin->library_name = GNUNET_strdup (library_name);
@@ -128,10 +125,7 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
128 125
129 ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context)); 126 ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context));
130 ctx->cfg = cfg; 127 ctx->cfg = cfg;
131 GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", 128 GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", NULL, &add_plugin, ctx);
132 NULL,
133 &add_plugin,
134 ctx);
135 return ctx; 129 return ctx;
136} 130}
137 131
@@ -147,7 +141,7 @@ GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
147 unsigned int i; 141 unsigned int i;
148 struct Plugin *plugin; 142 struct Plugin *plugin;
149 143
150 for (i = 0; i<ctx->num_plugins;i++) 144 for (i = 0; i < ctx->num_plugins; i++)
151 { 145 {
152 plugin = ctx->plugins[i]; 146 plugin = ctx->plugins[i];
153 GNUNET_break (NULL == 147 GNUNET_break (NULL ==
@@ -174,7 +168,7 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
174 unsigned int i; 168 unsigned int i;
175 unsigned int j; 169 unsigned int j;
176 170
177 for (i=0;i<ctx->num_plugins;i++) 171 for (i = 0; i < ctx->num_plugins; i++)
178 { 172 {
179 plugin = ctx->plugins[i]; 173 plugin = ctx->plugins[i];
180 j = 0; 174 j = 0;
@@ -291,8 +285,8 @@ compute_bloomfilter_size (unsigned int entry_count)
291 */ 285 */
292struct GNUNET_CONTAINER_BloomFilter * 286struct GNUNET_CONTAINER_BloomFilter *
293GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator, 287GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
294 const GNUNET_HashCode *seen_results, 288 const GNUNET_HashCode * seen_results,
295 unsigned int seen_results_count) 289 unsigned int seen_results_count)
296{ 290{
297 struct GNUNET_CONTAINER_BloomFilter *bf; 291 struct GNUNET_CONTAINER_BloomFilter *bf;
298 GNUNET_HashCode mhash; 292 GNUNET_HashCode mhash;
@@ -300,7 +294,8 @@ GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
300 size_t nsize; 294 size_t nsize;
301 295
302 nsize = compute_bloomfilter_size (seen_results_count); 296 nsize = compute_bloomfilter_size (seen_results_count);
303 bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize, GNUNET_CONSTANTS_BLOOMFILTER_K); 297 bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize,
298 GNUNET_CONSTANTS_BLOOMFILTER_K);
304 for (i = 0; i < seen_results_count; i++) 299 for (i = 0; i < seen_results_count; i++)
305 { 300 {
306 GNUNET_BLOCK_mingle_hash (&seen_results[i], bf_mutator, &mhash); 301 GNUNET_BLOCK_mingle_hash (&seen_results[i], bf_mutator, &mhash);
diff --git a/src/block/plugin_block_dht.c b/src/block/plugin_block_dht.c
index c58615b72..f574e6d06 100644
--- a/src/block/plugin_block_dht.c
+++ b/src/block/plugin_block_dht.c
@@ -77,19 +77,21 @@ block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
77 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) 77 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
78 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 78 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
79 if (NULL != bf) 79 if (NULL != bf)
80 {
81 GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash);
82 if (NULL != *bf)
83 {
84 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
85 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
86 }
87 else
80 { 88 {
81 GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash); 89 *bf =
82 if (NULL != *bf) 90 GNUNET_CONTAINER_bloomfilter_init (NULL, 8,
83 { 91 GNUNET_CONSTANTS_BLOOMFILTER_K);
84 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
85 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
86 }
87 else
88 {
89 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, GNUNET_CONSTANTS_BLOOMFILTER_K);
90 }
91 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
92 } 92 }
93 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
94 }
93 return GNUNET_BLOCK_EVALUATION_OK_MORE; 95 return GNUNET_BLOCK_EVALUATION_OK_MORE;
94} 96}
95 97
diff --git a/src/block/plugin_block_dns.c b/src/block/plugin_block_dns.c
index 8e8aa3047..b33b3798a 100644
--- a/src/block/plugin_block_dns.c
+++ b/src/block/plugin_block_dns.c
@@ -86,7 +86,8 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
86 } 86 }
87 87
88 if (GNUNET_TIME_relative_get_zero ().rel_value == 88 if (GNUNET_TIME_relative_get_zero ().rel_value ==
89 GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rec->expiration_time)).rel_value) 89 GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
90 (rec->expiration_time)).rel_value)
90 { 91 {
91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DNS-Block is invalid: Timeout\n"); 92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DNS-Block is invalid: Timeout\n");
92 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 93 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c
index 5a0e90a92..c1b4ad7c8 100644
--- a/src/block/plugin_block_fs.c
+++ b/src/block/plugin_block_fs.c
@@ -91,20 +91,20 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
91 if (reply_block == NULL) 91 if (reply_block == NULL)
92 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 92 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
93 if (NULL != bf) 93 if (NULL != bf)
94 {
95 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
96 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
97 if (NULL != *bf)
98 {
99 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
100 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
101 }
102 else
94 { 103 {
95 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 104 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
96 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
97 if (NULL != *bf)
98 {
99 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
100 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
101 }
102 else
103 {
104 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
105 }
106 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
107 } 105 }
106 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
107 }
108 return GNUNET_BLOCK_EVALUATION_OK_MORE; 108 return GNUNET_BLOCK_EVALUATION_OK_MORE;
109 case GNUNET_BLOCK_TYPE_FS_SBLOCK: 109 case GNUNET_BLOCK_TYPE_FS_SBLOCK:
110 if (xquery_size != sizeof (GNUNET_HashCode)) 110 if (xquery_size != sizeof (GNUNET_HashCode))
@@ -132,20 +132,20 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
132 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 132 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
133 } 133 }
134 if (NULL != bf) 134 if (NULL != bf)
135 {
136 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
137 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
138 if (NULL != *bf)
139 {
140 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
141 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
142 }
143 else
135 { 144 {
136 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 145 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
137 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
138 if (NULL != *bf)
139 {
140 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
141 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
142 }
143 else
144 {
145 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
146 }
147 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
148 } 146 }
147 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
148 }
149 return GNUNET_BLOCK_EVALUATION_OK_MORE; 149 return GNUNET_BLOCK_EVALUATION_OK_MORE;
150 default: 150 default:
151 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 151 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index 0c769b837..08d3096dc 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -75,14 +75,14 @@ block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
75 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 75 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
76 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); 76 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
77 if (NULL != *bf) 77 if (NULL != *bf)
78 { 78 {
79 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) 79 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
80 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; 80 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
81 } 81 }
82 else 82 else
83 { 83 {
84 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K); 84 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
85 } 85 }
86 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); 86 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
87 } 87 }
88 return GNUNET_BLOCK_EVALUATION_OK_MORE; 88 return GNUNET_BLOCK_EVALUATION_OK_MORE;