diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-01 07:46:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-01 07:46:18 +0000 |
commit | 15e69b2c40795016f3365ec2e75d3368a23d6013 (patch) | |
tree | c089d28b91676d62bfa89c22ec785bda26963123 /src/experimentation/gnunet-daemon-experimentation_experiments.c | |
parent | b7365c9a57b357d6f19f4f8101d3177e142a235c (diff) | |
download | gnunet-15e69b2c40795016f3365ec2e75d3368a23d6013.tar.gz gnunet-15e69b2c40795016f3365ec2e75d3368a23d6013.zip |
-just indentation
Diffstat (limited to 'src/experimentation/gnunet-daemon-experimentation_experiments.c')
-rw-r--r-- | src/experimentation/gnunet-daemon-experimentation_experiments.c | 191 |
1 files changed, 102 insertions, 89 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index c787c3416..5ca81393f 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -25,20 +25,18 @@ | |||
25 | * @author Matthias Wachs | 25 | * @author Matthias Wachs |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_getopt_lib.h" | ||
29 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
31 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
32 | #include "gnunet-daemon-experimentation.h" | 31 | #include "gnunet-daemon-experimentation.h" |
33 | 32 | ||
34 | 33 | ||
35 | |||
36 | /** | 34 | /** |
37 | * Struct to store information about an experiment issuer | 35 | * Struct to store information about an experiment issuer |
38 | */ | 36 | */ |
39 | struct Issuer | 37 | struct Issuer |
40 | { | 38 | { |
41 | struct GNUNET_CRYPTO_EccPublicSignKey pubkey; | 39 | struct GNUNET_CRYPTO_EccPublicSignKey pubkey; |
42 | }; | 40 | }; |
43 | 41 | ||
44 | 42 | ||
@@ -47,14 +45,13 @@ struct Issuer | |||
47 | */ | 45 | */ |
48 | static struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; | 46 | static struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; |
49 | 47 | ||
50 | |||
51 | /** | 48 | /** |
52 | * Hashmap containing valid experiments | 49 | * Hashmap containing valid experiments |
53 | */ | 50 | */ |
54 | static struct GNUNET_CONTAINER_MultiHashMap *experiments; | 51 | static struct GNUNET_CONTAINER_MultiHashMap *experiments; |
55 | 52 | ||
56 | 53 | ||
57 | uint32_t GSE_my_issuer_count; | 54 | static uint32_t GSE_my_issuer_count; |
58 | 55 | ||
59 | /** | 56 | /** |
60 | * Valid experiment issuer for this daemon | 57 | * Valid experiment issuer for this daemon |
@@ -74,23 +71,26 @@ struct Experimentation_Issuer *GSE_my_issuer; | |||
74 | int | 71 | int |
75 | experiment_verify (struct Issuer *i, struct Experiment *e) | 72 | experiment_verify (struct Issuer *i, struct Experiment *e) |
76 | { | 73 | { |
77 | GNUNET_assert (NULL != i); | 74 | GNUNET_assert (NULL != i); |
78 | GNUNET_assert (NULL != e); | 75 | GNUNET_assert (NULL != e); |
79 | 76 | ||
80 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Verification: to be implemented\n"); | 77 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
81 | return GNUNET_OK; | 78 | "Verification: to be implemented\n"); |
79 | return GNUNET_OK; | ||
82 | } | 80 | } |
83 | 81 | ||
84 | int free_experiment (void *cls, | 82 | int |
85 | const struct GNUNET_HashCode * key, | 83 | free_experiment (void *cls, |
86 | void *value) | 84 | const struct GNUNET_HashCode * key, |
85 | void *value) | ||
87 | { | 86 | { |
88 | struct Experiment *e = value; | 87 | struct Experiment *e = value; |
89 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (experiments, key, value)); | 88 | |
90 | GNUNET_free_non_null (e->description); | 89 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (experiments, key, value)); |
91 | GNUNET_free_non_null (e->name); | 90 | GNUNET_free_non_null (e->description); |
92 | GNUNET_free (e); | 91 | GNUNET_free_non_null (e->name); |
93 | return GNUNET_OK; | 92 | GNUNET_free (e); |
93 | return GNUNET_OK; | ||
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
@@ -102,27 +102,31 @@ int free_experiment (void *cls, | |||
102 | * @param value the issuer element to free | 102 | * @param value the issuer element to free |
103 | * @return GNUNET_OK to continue | 103 | * @return GNUNET_OK to continue |
104 | */ | 104 | */ |
105 | int free_issuer (void *cls, | 105 | int |
106 | const struct GNUNET_HashCode * key, | 106 | free_issuer (void *cls, |
107 | void *value) | 107 | const struct GNUNET_HashCode * key, |
108 | void *value) | ||
108 | { | 109 | { |
109 | struct Issuer *i = value; | 110 | struct Issuer *i = value; |
110 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (valid_issuers, key, value)); | 111 | |
111 | GNUNET_free (i); | 112 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (valid_issuers, key, value)); |
112 | return GNUNET_OK; | 113 | GNUNET_free (i); |
114 | return GNUNET_OK; | ||
113 | } | 115 | } |
114 | 116 | ||
115 | int create_issuer (void *cls, | ||
116 | const struct GNUNET_HashCode * key, | ||
117 | void *value) | ||
118 | { | ||
119 | static int i = 0; | ||
120 | GNUNET_assert (i < GSE_my_issuer_count); | ||
121 | GSE_my_issuer[i].issuer_id.hashPubKey = *key; | ||
122 | 117 | ||
123 | i++; | 118 | int |
124 | return GNUNET_OK; | 119 | create_issuer (void *cls, |
120 | const struct GNUNET_HashCode * key, | ||
121 | void *value) | ||
122 | { | ||
123 | static int i = 0; | ||
125 | 124 | ||
125 | GNUNET_assert (i < GSE_my_issuer_count); | ||
126 | GSE_my_issuer[i].issuer_id.hashPubKey = *key; | ||
127 | |||
128 | i++; | ||
129 | return GNUNET_OK; | ||
126 | } | 130 | } |
127 | 131 | ||
128 | 132 | ||
@@ -135,34 +139,36 @@ int create_issuer (void *cls, | |||
135 | int | 139 | int |
136 | GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID) | 140 | GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID) |
137 | { | 141 | { |
138 | if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &issuer_ID->hashPubKey)) | 142 | if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &issuer_ID->hashPubKey)) |
139 | return GNUNET_YES; | 143 | return GNUNET_YES; |
140 | else | 144 | else |
141 | return GNUNET_NO; | 145 | return GNUNET_NO; |
142 | } | 146 | } |
143 | 147 | ||
148 | |||
144 | struct FindCtx | 149 | struct FindCtx |
145 | { | 150 | { |
146 | const char *name; | 151 | const char *name; |
147 | struct GNUNET_TIME_Absolute version; | 152 | struct GNUNET_TIME_Absolute version; |
148 | struct Experiment *res; | 153 | struct Experiment *res; |
149 | }; | 154 | }; |
150 | 155 | ||
156 | |||
151 | static int | 157 | static int |
152 | find_it (void *cls, | 158 | find_it (void *cls, |
153 | const struct GNUNET_HashCode * key, | 159 | const struct GNUNET_HashCode * key, |
154 | void *value) | 160 | void *value) |
155 | { | 161 | { |
156 | struct FindCtx *find_ctx = cls; | 162 | struct FindCtx *find_ctx = cls; |
157 | struct Experiment *e = (struct Experiment *) value; | 163 | struct Experiment *e = (struct Experiment *) value; |
158 | 164 | ||
159 | if (0 != strcmp(e->name, find_ctx->name)) | 165 | if (0 != strcmp(e->name, find_ctx->name)) |
160 | return GNUNET_OK; | 166 | return GNUNET_OK; |
161 | if (e->version.abs_value_us != find_ctx->version.abs_value_us) | 167 | if (e->version.abs_value_us != find_ctx->version.abs_value_us) |
162 | return GNUNET_OK; | 168 | return GNUNET_OK; |
163 | 169 | ||
164 | find_ctx->res = e; | 170 | find_ctx->res = e; |
165 | return GNUNET_NO; | 171 | return GNUNET_NO; |
166 | } | 172 | } |
167 | 173 | ||
168 | 174 | ||
@@ -176,44 +182,47 @@ find_it (void *cls, | |||
176 | */ | 182 | */ |
177 | struct Experiment * | 183 | struct Experiment * |
178 | GED_experiments_find (const struct GNUNET_PeerIdentity *issuer, | 184 | GED_experiments_find (const struct GNUNET_PeerIdentity *issuer, |
179 | const char *name, | 185 | const char *name, |
180 | const struct GNUNET_TIME_Absolute version) | 186 | const struct GNUNET_TIME_Absolute version) |
181 | { | 187 | { |
182 | struct FindCtx find_ctx; | 188 | struct FindCtx find_ctx; |
183 | 189 | ||
184 | find_ctx.name = name; | 190 | find_ctx.name = name; |
185 | find_ctx.version = version; | 191 | find_ctx.version = version; |
186 | find_ctx.res = NULL; | 192 | find_ctx.res = NULL; |
187 | 193 | ||
188 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, | 194 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, |
189 | &issuer->hashPubKey, &find_it, &find_ctx); | 195 | &issuer->hashPubKey, |
190 | return find_ctx.res; | 196 | &find_it, &find_ctx); |
197 | return find_ctx.res; | ||
191 | } | 198 | } |
192 | 199 | ||
200 | |||
193 | struct GetCtx | 201 | struct GetCtx |
194 | { | 202 | { |
195 | struct Node *n; | 203 | struct Node *n; |
196 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb; | 204 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb; |
197 | }; | 205 | }; |
198 | 206 | ||
199 | 207 | ||
200 | static int | 208 | static int |
201 | get_it (void *cls, | 209 | get_it (void *cls, |
202 | const struct GNUNET_HashCode * key, | 210 | const struct GNUNET_HashCode * key, |
203 | void *value) | 211 | void *value) |
204 | { | 212 | { |
205 | struct GetCtx *get_ctx = cls; | 213 | struct GetCtx *get_ctx = cls; |
206 | struct Experiment *e = value; | 214 | struct Experiment *e = value; |
207 | 215 | ||
208 | get_ctx->get_cb (get_ctx->n, e); | 216 | get_ctx->get_cb (get_ctx->n, e); |
209 | 217 | ||
210 | return GNUNET_OK; | 218 | return GNUNET_OK; |
211 | } | 219 | } |
212 | 220 | ||
221 | |||
213 | void | 222 | void |
214 | GED_experiments_get (struct Node *n, | 223 | GED_experiments_get (struct Node *n, |
215 | struct GNUNET_PeerIdentity *issuer, | 224 | struct GNUNET_PeerIdentity *issuer, |
216 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) | 225 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) |
217 | { | 226 | { |
218 | struct GetCtx get_ctx; | 227 | struct GetCtx get_ctx; |
219 | 228 | ||
@@ -230,22 +239,25 @@ GED_experiments_get (struct Node *n, | |||
230 | get_cb (n, NULL); | 239 | get_cb (n, NULL); |
231 | } | 240 | } |
232 | 241 | ||
242 | |||
233 | /** | 243 | /** |
234 | * Add a new experiment | 244 | * Add a new experiment |
235 | */ | 245 | */ |
236 | int GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | 246 | int |
237 | const char *name, | 247 | GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, |
238 | struct GNUNET_PeerIdentity issuer_id, | 248 | const char *name, |
239 | struct GNUNET_TIME_Absolute version, | 249 | struct GNUNET_PeerIdentity issuer_id, |
240 | char *description, | 250 | struct GNUNET_TIME_Absolute version, |
241 | uint32_t required_capabilities, | 251 | char *description, |
242 | struct GNUNET_TIME_Absolute start, | 252 | uint32_t required_capabilities, |
243 | struct GNUNET_TIME_Relative frequency, | 253 | struct GNUNET_TIME_Absolute start, |
244 | struct GNUNET_TIME_Relative duration, | 254 | struct GNUNET_TIME_Relative frequency, |
245 | struct GNUNET_TIME_Absolute stop) | 255 | struct GNUNET_TIME_Relative duration, |
256 | struct GNUNET_TIME_Absolute stop) | ||
246 | { | 257 | { |
247 | struct Experiment *e; | 258 | struct Experiment *e; |
248 | e = GNUNET_malloc (sizeof (struct Experiment)); | 259 | |
260 | e = GNUNET_new (struct Experiment); | ||
249 | 261 | ||
250 | e->name = GNUNET_strdup (name); | 262 | e->name = GNUNET_strdup (name); |
251 | e->issuer = issuer_id; | 263 | e->issuer = issuer_id; |
@@ -287,8 +299,9 @@ int GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | |||
287 | * @param cls configuration handle | 299 | * @param cls configuration handle |
288 | * @param name section name | 300 | * @param name section name |
289 | */ | 301 | */ |
290 | void exp_file_iterator (void *cls, | 302 | void |
291 | const char *name) | 303 | exp_file_iterator (void *cls, |
304 | const char *name) | ||
292 | { | 305 | { |
293 | struct GNUNET_CONFIGURATION_Handle *exp = cls; | 306 | struct GNUNET_CONFIGURATION_Handle *exp = cls; |
294 | struct Issuer *i; | 307 | struct Issuer *i; |