aboutsummaryrefslogtreecommitdiff
path: root/src/identity
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/identity
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/identity')
-rw-r--r--src/identity/gnunet-identity.c334
-rw-r--r--src/identity/gnunet-service-identity.c1004
-rw-r--r--src/identity/identity.h27
-rw-r--r--src/identity/identity_api.c590
-rw-r--r--src/identity/identity_api_lookup.c117
-rw-r--r--src/identity/identity_api_suffix_lookup.c120
-rw-r--r--src/identity/plugin_rest_identity.c1089
-rw-r--r--src/identity/test_identity.c230
-rw-r--r--src/identity/test_identity_defaults.c176
9 files changed, 1854 insertions, 1833 deletions
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index d86fd2166..6a5b1b1ca 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -112,29 +112,29 @@ static int global_ret;
112 * @param cls NULL 112 * @param cls NULL
113 */ 113 */
114static void 114static void
115shutdown_task(void *cls) 115shutdown_task (void *cls)
116{ 116{
117 if (NULL != set_op) 117 if (NULL != set_op)
118 { 118 {
119 GNUNET_IDENTITY_cancel(set_op); 119 GNUNET_IDENTITY_cancel (set_op);
120 set_op = NULL; 120 set_op = NULL;
121 } 121 }
122 if (NULL != create_op) 122 if (NULL != create_op)
123 { 123 {
124 GNUNET_IDENTITY_cancel(create_op); 124 GNUNET_IDENTITY_cancel (create_op);
125 create_op = NULL; 125 create_op = NULL;
126 } 126 }
127 if (NULL != delete_op) 127 if (NULL != delete_op)
128 { 128 {
129 GNUNET_IDENTITY_cancel(delete_op); 129 GNUNET_IDENTITY_cancel (delete_op);
130 delete_op = NULL; 130 delete_op = NULL;
131 } 131 }
132 if (NULL != set_ego) 132 if (NULL != set_ego)
133 { 133 {
134 GNUNET_free(set_ego); 134 GNUNET_free (set_ego);
135 set_ego = NULL; 135 set_ego = NULL;
136 } 136 }
137 GNUNET_IDENTITY_disconnect(sh); 137 GNUNET_IDENTITY_disconnect (sh);
138 sh = NULL; 138 sh = NULL;
139} 139}
140 140
@@ -143,15 +143,15 @@ shutdown_task(void *cls)
143 * Test if we are finished yet. 143 * Test if we are finished yet.
144 */ 144 */
145static void 145static void
146test_finished() 146test_finished ()
147{ 147{
148 if ((NULL == create_op) && (NULL == delete_op) && (NULL == set_op) && 148 if ((NULL == create_op) && (NULL == delete_op) && (NULL == set_op) &&
149 (NULL == set_subsystem) && (!list) && (!monitor)) 149 (NULL == set_subsystem) && (! list) && (! monitor))
150 { 150 {
151 if (TIMEOUT_STATUS_CODE == global_ret) 151 if (TIMEOUT_STATUS_CODE == global_ret)
152 global_ret = 0; 152 global_ret = 0;
153 GNUNET_SCHEDULER_shutdown(); 153 GNUNET_SCHEDULER_shutdown ();
154 } 154 }
155} 155}
156 156
157 157
@@ -162,14 +162,14 @@ test_finished()
162 * @param emsg NULL on success, otherwise an error message 162 * @param emsg NULL on success, otherwise an error message
163 */ 163 */
164static void 164static void
165delete_finished(void *cls, const char *emsg) 165delete_finished (void *cls, const char *emsg)
166{ 166{
167 struct GNUNET_IDENTITY_Operation **op = cls; 167 struct GNUNET_IDENTITY_Operation **op = cls;
168 168
169 *op = NULL; 169 *op = NULL;
170 if (NULL != emsg) 170 if (NULL != emsg)
171 fprintf(stderr, "%s\n", gettext(emsg)); 171 fprintf (stderr, "%s\n", gettext (emsg));
172 test_finished(); 172 test_finished ();
173} 173}
174 174
175 175
@@ -181,40 +181,40 @@ delete_finished(void *cls, const char *emsg)
181 * @param emsg error message, NULL on success 181 * @param emsg error message, NULL on success
182 */ 182 */
183static void 183static void
184create_finished(void *cls, 184create_finished (void *cls,
185 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 185 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
186 const char *emsg) 186 const char *emsg)
187{ 187{
188 struct GNUNET_IDENTITY_Operation **op = cls; 188 struct GNUNET_IDENTITY_Operation **op = cls;
189 189
190 *op = NULL; 190 *op = NULL;
191 if (NULL == pk) 191 if (NULL == pk)
192 { 192 {
193 fprintf(stderr, _("Failed to create ego: %s\n"), emsg); 193 fprintf (stderr, _ ("Failed to create ego: %s\n"), emsg);
194 global_ret = 1; 194 global_ret = 1;
195 } 195 }
196 else if (verbose) 196 else if (verbose)
197 { 197 {
198 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 198 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
199 char *pubs; 199 char *pubs;
200 200
201 GNUNET_CRYPTO_ecdsa_key_get_public(pk, &pub); 201 GNUNET_CRYPTO_ecdsa_key_get_public (pk, &pub);
202 pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pub); 202 pubs = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub);
203 if (private_keys) 203 if (private_keys)
204 { 204 {
205 char *privs; 205 char *privs;
206 206
207 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string(pk); 207 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string (pk);
208 fprintf(stdout, "%s - %s\n", pubs, privs); 208 fprintf (stdout, "%s - %s\n", pubs, privs);
209 GNUNET_free(privs); 209 GNUNET_free (privs);
210 } 210 }
211 else 211 else
212 { 212 {
213 fprintf(stdout, "%s\n", pubs); 213 fprintf (stdout, "%s\n", pubs);
214 }
215 GNUNET_free(pubs);
216 } 214 }
217 test_finished(); 215 GNUNET_free (pubs);
216 }
217 test_finished ();
218} 218}
219 219
220 220
@@ -225,15 +225,15 @@ create_finished(void *cls,
225 * @param emsg error message (NULL on success) 225 * @param emsg error message (NULL on success)
226 */ 226 */
227static void 227static void
228set_done(void *cls, const char *emsg) 228set_done (void *cls, const char *emsg)
229{ 229{
230 set_op = NULL; 230 set_op = NULL;
231 if (NULL != emsg) 231 if (NULL != emsg)
232 { 232 {
233 fprintf(stderr, _("Failed to set default ego: %s\n"), emsg); 233 fprintf (stderr, _ ("Failed to set default ego: %s\n"), emsg);
234 global_ret = 1; 234 global_ret = 1;
235 } 235 }
236 test_finished(); 236 test_finished ();
237} 237}
238 238
239 239
@@ -271,70 +271,70 @@ set_done(void *cls, const char *emsg)
271 * must thus no longer be used 271 * must thus no longer be used
272 */ 272 */
273static void 273static void
274print_ego(void *cls, 274print_ego (void *cls,
275 struct GNUNET_IDENTITY_Ego *ego, 275 struct GNUNET_IDENTITY_Ego *ego,
276 void **ctx, 276 void **ctx,
277 const char *identifier) 277 const char *identifier)
278{ 278{
279 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 279 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
280 char *s; 280 char *s;
281 char *privs; 281 char *privs;
282 282
283 if ((NULL != set_ego) && (NULL != set_subsystem) && (NULL != ego) && 283 if ((NULL != set_ego) && (NULL != set_subsystem) && (NULL != ego) &&
284 (NULL != identifier) && (0 == strcmp(identifier, set_ego))) 284 (NULL != identifier) && (0 == strcmp (identifier, set_ego)))
285 { 285 {
286 set_op = GNUNET_IDENTITY_set(sh, set_subsystem, ego, &set_done, NULL); 286 set_op = GNUNET_IDENTITY_set (sh, set_subsystem, ego, &set_done, NULL);
287 GNUNET_free(set_subsystem); 287 GNUNET_free (set_subsystem);
288 set_subsystem = NULL; 288 set_subsystem = NULL;
289 GNUNET_free(set_ego); 289 GNUNET_free (set_ego);
290 set_ego = NULL; 290 set_ego = NULL;
291 } 291 }
292 if ((NULL == ego) && (NULL != set_ego) && (NULL != set_subsystem)) 292 if ((NULL == ego) && (NULL != set_ego) && (NULL != set_subsystem))
293 { 293 {
294 fprintf(stderr, 294 fprintf (stderr,
295 "Could not set ego to `%s' for subsystem `%s', ego not known\n", 295 "Could not set ego to `%s' for subsystem `%s', ego not known\n",
296 set_ego, 296 set_ego,
297 set_subsystem); 297 set_subsystem);
298 GNUNET_free(set_subsystem); 298 GNUNET_free (set_subsystem);
299 set_subsystem = NULL; 299 set_subsystem = NULL;
300 GNUNET_free(set_ego); 300 GNUNET_free (set_ego);
301 set_ego = NULL; 301 set_ego = NULL;
302 } 302 }
303 if ((NULL == ego) && (!monitor)) 303 if ((NULL == ego) && (! monitor))
304 { 304 {
305 list = 0; 305 list = 0;
306 test_finished(); 306 test_finished ();
307 return; 307 return;
308 } 308 }
309 if (!(list | monitor)) 309 if (! (list | monitor))
310 return; 310 return;
311 if ((NULL == ego) || (NULL == identifier)) 311 if ((NULL == ego) || (NULL == identifier))
312 return; 312 return;
313 if ((NULL != set_ego) && (0 != strcmp(identifier, set_ego))) 313 if ((NULL != set_ego) && (0 != strcmp (identifier, set_ego)))
314 return; 314 return;
315 GNUNET_IDENTITY_ego_get_public_key(ego, &pk); 315 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
316 s = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pk); 316 s = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
317 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string( 317 privs = GNUNET_CRYPTO_ecdsa_private_key_to_string (
318 GNUNET_IDENTITY_ego_get_private_key(ego)); 318 GNUNET_IDENTITY_ego_get_private_key (ego));
319 if ((monitor) || (NULL != identifier)) 319 if ((monitor) || (NULL != identifier))
320 {
321 if (quiet)
320 { 322 {
321 if (quiet) 323 if (private_keys)
322 { 324 fprintf (stdout, "%s - %s\n", s, privs);
323 if (private_keys) 325 else
324 fprintf(stdout, "%s - %s\n", s, privs); 326 fprintf (stdout, "%s\n", s);
325 else 327 }
326 fprintf(stdout, "%s\n", s); 328 else
327 } 329 {
330 if (private_keys)
331 fprintf (stdout, "%s - %s - %s\n", identifier, s, privs);
328 else 332 else
329 { 333 fprintf (stdout, "%s - %s\n", identifier, s);
330 if (private_keys)
331 fprintf(stdout, "%s - %s - %s\n", identifier, s, privs);
332 else
333 fprintf(stdout, "%s - %s\n", identifier, s);
334 }
335 } 334 }
336 GNUNET_free(privs); 335 }
337 GNUNET_free(s); 336 GNUNET_free (privs);
337 GNUNET_free (s);
338} 338}
339 339
340 340
@@ -347,30 +347,30 @@ print_ego(void *cls,
347 * @param cfg configuration 347 * @param cfg configuration
348 */ 348 */
349static void 349static void
350run(void *cls, 350run (void *cls,
351 char *const *args, 351 char *const *args,
352 const char *cfgfile, 352 const char *cfgfile,
353 const struct GNUNET_CONFIGURATION_Handle *cfg) 353 const struct GNUNET_CONFIGURATION_Handle *cfg)
354{ 354{
355 if ((NULL != set_subsystem) && (NULL == set_ego)) 355 if ((NULL != set_subsystem) && (NULL == set_ego))
356 { 356 {
357 fprintf(stderr, "Option -s requires option -e to be specified as well.\n"); 357 fprintf (stderr, "Option -s requires option -e to be specified as well.\n");
358 return; 358 return;
359 } 359 }
360 sh = GNUNET_IDENTITY_connect(cfg, 360 sh = GNUNET_IDENTITY_connect (cfg,
361 (monitor | list) || (NULL != set_ego) || 361 (monitor | list) || (NULL != set_ego) ||
362 (NULL != set_subsystem) 362 (NULL != set_subsystem)
363 ? &print_ego 363 ? &print_ego
364 : NULL, 364 : NULL,
365 NULL); 365 NULL);
366 if (NULL != delete_ego) 366 if (NULL != delete_ego)
367 delete_op = 367 delete_op =
368 GNUNET_IDENTITY_delete(sh, delete_ego, &delete_finished, &delete_op); 368 GNUNET_IDENTITY_delete (sh, delete_ego, &delete_finished, &delete_op);
369 if (NULL != create_ego) 369 if (NULL != create_ego)
370 create_op = 370 create_op =
371 GNUNET_IDENTITY_create(sh, create_ego, &create_finished, &create_op); 371 GNUNET_IDENTITY_create (sh, create_ego, &create_finished, &create_op);
372 GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); 372 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
373 test_finished(); 373 test_finished ();
374} 374}
375 375
376 376
@@ -382,64 +382,64 @@ run(void *cls,
382 * @return 0 ok, 1 on error 382 * @return 0 ok, 1 on error
383 */ 383 */
384int 384int
385main(int argc, char *const *argv) 385main (int argc, char *const *argv)
386{ 386{
387 struct GNUNET_GETOPT_CommandLineOption options[] = 387 struct GNUNET_GETOPT_CommandLineOption options[] =
388 { GNUNET_GETOPT_option_string('C', 388 { GNUNET_GETOPT_option_string ('C',
389 "create", 389 "create",
390 "NAME", 390 "NAME",
391 gettext_noop("create ego NAME"), 391 gettext_noop ("create ego NAME"),
392 &create_ego), 392 &create_ego),
393 GNUNET_GETOPT_option_string('D', 393 GNUNET_GETOPT_option_string ('D',
394 "delete", 394 "delete",
395 "NAME", 395 "NAME",
396 gettext_noop("delete ego NAME "), 396 gettext_noop ("delete ego NAME "),
397 &delete_ego), 397 &delete_ego),
398 GNUNET_GETOPT_option_flag('d', 398 GNUNET_GETOPT_option_flag ('d',
399 "display", 399 "display",
400 gettext_noop("display all egos"), 400 gettext_noop ("display all egos"),
401 &list), 401 &list),
402 GNUNET_GETOPT_option_flag('q', 402 GNUNET_GETOPT_option_flag ('q',
403 "quiet", 403 "quiet",
404 gettext_noop("reduce output"), 404 gettext_noop ("reduce output"),
405 &quiet), 405 &quiet),
406 GNUNET_GETOPT_option_string( 406 GNUNET_GETOPT_option_string (
407 'e', 407 'e',
408 "ego", 408 "ego",
409 "NAME", 409 "NAME",
410 gettext_noop( 410 gettext_noop (
411 "set default identity to NAME for a subsystem SUBSYSTEM (use together with -s) or restrict results to NAME (use together with -d)"), 411 "set default identity to NAME for a subsystem SUBSYSTEM (use together with -s) or restrict results to NAME (use together with -d)"),
412 &set_ego), 412 &set_ego),
413 GNUNET_GETOPT_option_flag('m', 413 GNUNET_GETOPT_option_flag ('m',
414 "monitor", 414 "monitor",
415 gettext_noop("run in monitor mode egos"), 415 gettext_noop ("run in monitor mode egos"),
416 &monitor), 416 &monitor),
417 GNUNET_GETOPT_option_flag('p', 417 GNUNET_GETOPT_option_flag ('p',
418 "private-keys", 418 "private-keys",
419 gettext_noop("display private keys as well"), 419 gettext_noop ("display private keys as well"),
420 &private_keys), 420 &private_keys),
421 GNUNET_GETOPT_option_string( 421 GNUNET_GETOPT_option_string (
422 's', 422 's',
423 "set", 423 "set",
424 "SUBSYSTEM", 424 "SUBSYSTEM",
425 gettext_noop( 425 gettext_noop (
426 "set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"), 426 "set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
427 &set_subsystem), 427 &set_subsystem),
428 GNUNET_GETOPT_option_verbose(&verbose), 428 GNUNET_GETOPT_option_verbose (&verbose),
429 GNUNET_GETOPT_OPTION_END }; 429 GNUNET_GETOPT_OPTION_END };
430 int res; 430 int res;
431 431
432 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 432 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
433 return 4; 433 return 4;
434 global_ret = TIMEOUT_STATUS_CODE; /* timeout */ 434 global_ret = TIMEOUT_STATUS_CODE; /* timeout */
435 res = GNUNET_PROGRAM_run(argc, 435 res = GNUNET_PROGRAM_run (argc,
436 argv, 436 argv,
437 "gnunet-identity", 437 "gnunet-identity",
438 gettext_noop("Maintain egos"), 438 gettext_noop ("Maintain egos"),
439 options, 439 options,
440 &run, 440 &run,
441 NULL); 441 NULL);
442 GNUNET_free((void *)argv); 442 GNUNET_free ((void *) argv);
443 443
444 if (GNUNET_OK != res) 444 if (GNUNET_OK != res)
445 return 3; 445 return 3;
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index f399b2566..98b5bde45 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -42,7 +42,8 @@
42/** 42/**
43 * Information we keep about each ego. 43 * Information we keep about each ego.
44 */ 44 */
45struct Ego { 45struct Ego
46{
46 /** 47 /**
47 * We keep egos in a DLL. 48 * We keep egos in a DLL.
48 */ 49 */
@@ -114,15 +115,15 @@ static struct Ego *ego_tail;
114 * @return full filename for the given ego 115 * @return full filename for the given ego
115 */ 116 */
116static char * 117static char *
117get_ego_filename(struct Ego *ego) 118get_ego_filename (struct Ego *ego)
118{ 119{
119 char *filename; 120 char *filename;
120 121
121 GNUNET_asprintf(&filename, 122 GNUNET_asprintf (&filename,
122 "%s%s%s", 123 "%s%s%s",
123 ego_directory, 124 ego_directory,
124 DIR_SEPARATOR_STR, 125 DIR_SEPARATOR_STR,
125 ego->identifier); 126 ego->identifier);
126 return filename; 127 return filename;
127} 128}
128 129
@@ -134,11 +135,11 @@ get_ego_filename(struct Ego *ego)
134 * @param app_ctx @a client 135 * @param app_ctx @a client
135 */ 136 */
136static void 137static void
137client_disconnect_cb(void *cls, 138client_disconnect_cb (void *cls,
138 struct GNUNET_SERVICE_Client *client, 139 struct GNUNET_SERVICE_Client *client,
139 void *app_ctx) 140 void *app_ctx)
140{ 141{
141 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); 142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
142} 143}
143 144
144 145
@@ -151,9 +152,9 @@ client_disconnect_cb(void *cls,
151 * @return internal namestore client structure for this client 152 * @return internal namestore client structure for this client
152 */ 153 */
153static void * 154static void *
154client_connect_cb(void *cls, 155client_connect_cb (void *cls,
155 struct GNUNET_SERVICE_Client *client, 156 struct GNUNET_SERVICE_Client *client,
156 struct GNUNET_MQ_Handle *mq) 157 struct GNUNET_MQ_Handle *mq)
157{ 158{
158 return client; 159 return client;
159} 160}
@@ -164,33 +165,33 @@ client_connect_cb(void *cls,
164 * @param cls unused 165 * @param cls unused
165 */ 166 */
166static void 167static void
167shutdown_task(void *cls) 168shutdown_task (void *cls)
168{ 169{
169 struct Ego *e; 170 struct Ego *e;
170 171
171 if (NULL != nc) 172 if (NULL != nc)
172 { 173 {
173 GNUNET_notification_context_destroy(nc); 174 GNUNET_notification_context_destroy (nc);
174 nc = NULL; 175 nc = NULL;
175 } 176 }
176 if (NULL != stats) 177 if (NULL != stats)
177 { 178 {
178 GNUNET_STATISTICS_destroy(stats, GNUNET_NO); 179 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
179 stats = NULL; 180 stats = NULL;
180 } 181 }
181 GNUNET_CONFIGURATION_destroy(subsystem_cfg); 182 GNUNET_CONFIGURATION_destroy (subsystem_cfg);
182 subsystem_cfg = NULL; 183 subsystem_cfg = NULL;
183 GNUNET_free(subsystem_cfg_file); 184 GNUNET_free (subsystem_cfg_file);
184 subsystem_cfg_file = NULL; 185 subsystem_cfg_file = NULL;
185 GNUNET_free(ego_directory); 186 GNUNET_free (ego_directory);
186 ego_directory = NULL; 187 ego_directory = NULL;
187 while (NULL != (e = ego_head)) 188 while (NULL != (e = ego_head))
188 { 189 {
189 GNUNET_CONTAINER_DLL_remove(ego_head, ego_tail, e); 190 GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e);
190 GNUNET_free(e->pk); 191 GNUNET_free (e->pk);
191 GNUNET_free(e->identifier); 192 GNUNET_free (e->identifier);
192 GNUNET_free(e); 193 GNUNET_free (e);
193 } 194 }
194} 195}
195 196
196 197
@@ -202,9 +203,9 @@ shutdown_task(void *cls)
202 * @param emsg error message to include (or NULL for none) 203 * @param emsg error message to include (or NULL for none)
203 */ 204 */
204static void 205static void
205send_result_code(struct GNUNET_SERVICE_Client *client, 206send_result_code (struct GNUNET_SERVICE_Client *client,
206 uint32_t result_code, 207 uint32_t result_code,
207 const char *emsg) 208 const char *emsg)
208{ 209{
209 struct ResultCodeMessage *rcm; 210 struct ResultCodeMessage *rcm;
210 struct GNUNET_MQ_Envelope *env; 211 struct GNUNET_MQ_Envelope *env;
@@ -213,17 +214,17 @@ send_result_code(struct GNUNET_SERVICE_Client *client,
213 if (NULL == emsg) 214 if (NULL == emsg)
214 elen = 0; 215 elen = 0;
215 else 216 else
216 elen = strlen(emsg) + 1; 217 elen = strlen (emsg) + 1;
217 env = 218 env =
218 GNUNET_MQ_msg_extra(rcm, elen, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE); 219 GNUNET_MQ_msg_extra (rcm, elen, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
219 rcm->result_code = htonl(result_code); 220 rcm->result_code = htonl (result_code);
220 if (0 < elen) 221 if (0 < elen)
221 GNUNET_memcpy(&rcm[1], emsg, elen); 222 GNUNET_memcpy (&rcm[1], emsg, elen);
222 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
223 "Sending result %d (%s) to client\n", 224 "Sending result %d (%s) to client\n",
224 (int)result_code, 225 (int) result_code,
225 emsg); 226 emsg);
226 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 227 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
227} 228}
228 229
229 230
@@ -234,18 +235,18 @@ send_result_code(struct GNUNET_SERVICE_Client *client,
234 * @return corresponding update message 235 * @return corresponding update message
235 */ 236 */
236static struct GNUNET_MQ_Envelope * 237static struct GNUNET_MQ_Envelope *
237create_update_message(struct Ego *ego) 238create_update_message (struct Ego *ego)
238{ 239{
239 struct UpdateMessage *um; 240 struct UpdateMessage *um;
240 struct GNUNET_MQ_Envelope *env; 241 struct GNUNET_MQ_Envelope *env;
241 size_t name_len; 242 size_t name_len;
242 243
243 name_len = (NULL == ego->identifier) ? 0 : (strlen(ego->identifier) + 1); 244 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
244 env = GNUNET_MQ_msg_extra(um, name_len, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 245 env = GNUNET_MQ_msg_extra (um, name_len, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
245 um->name_len = htons(name_len); 246 um->name_len = htons (name_len);
246 um->end_of_list = htons(GNUNET_NO); 247 um->end_of_list = htons (GNUNET_NO);
247 um->private_key = *ego->pk; 248 um->private_key = *ego->pk;
248 GNUNET_memcpy(&um[1], ego->identifier, name_len); 249 GNUNET_memcpy (&um[1], ego->identifier, name_len);
249 return env; 250 return env;
250} 251}
251 252
@@ -258,20 +259,20 @@ create_update_message(struct Ego *ego)
258 * @return corresponding set default message 259 * @return corresponding set default message
259 */ 260 */
260static struct GNUNET_MQ_Envelope * 261static struct GNUNET_MQ_Envelope *
261create_set_default_message(struct Ego *ego, const char *servicename) 262create_set_default_message (struct Ego *ego, const char *servicename)
262{ 263{
263 struct SetDefaultMessage *sdm; 264 struct SetDefaultMessage *sdm;
264 struct GNUNET_MQ_Envelope *env; 265 struct GNUNET_MQ_Envelope *env;
265 size_t name_len; 266 size_t name_len;
266 267
267 name_len = (NULL == servicename) ? 0 : (strlen(servicename) + 1); 268 name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1);
268 env = GNUNET_MQ_msg_extra(sdm, 269 env = GNUNET_MQ_msg_extra (sdm,
269 name_len, 270 name_len,
270 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); 271 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
271 sdm->name_len = htons(name_len); 272 sdm->name_len = htons (name_len);
272 sdm->reserved = htons(0); 273 sdm->reserved = htons (0);
273 sdm->private_key = *ego->pk; 274 sdm->private_key = *ego->pk;
274 GNUNET_memcpy(&sdm[1], servicename, name_len); 275 GNUNET_memcpy (&sdm[1], servicename, name_len);
275 return env; 276 return env;
276} 277}
277 278
@@ -286,27 +287,27 @@ create_set_default_message(struct Ego *ego, const char *servicename)
286 * @param message the message received 287 * @param message the message received
287 */ 288 */
288static void 289static void
289handle_start_message(void *cls, const struct GNUNET_MessageHeader *message) 290handle_start_message (void *cls, const struct GNUNET_MessageHeader *message)
290{ 291{
291 struct GNUNET_SERVICE_Client *client = cls; 292 struct GNUNET_SERVICE_Client *client = cls;
292 struct UpdateMessage *ume; 293 struct UpdateMessage *ume;
293 struct GNUNET_MQ_Envelope *env; 294 struct GNUNET_MQ_Envelope *env;
294 struct Ego *ego; 295 struct Ego *ego;
295 296
296 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); 297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
297 GNUNET_SERVICE_client_mark_monitor(client); 298 GNUNET_SERVICE_client_mark_monitor (client);
298 GNUNET_SERVICE_client_disable_continue_warning(client); 299 GNUNET_SERVICE_client_disable_continue_warning (client);
299 GNUNET_notification_context_add(nc, GNUNET_SERVICE_client_get_mq(client)); 300 GNUNET_notification_context_add (nc, GNUNET_SERVICE_client_get_mq (client));
300 for (ego = ego_head; NULL != ego; ego = ego->next) 301 for (ego = ego_head; NULL != ego; ego = ego->next)
301 { 302 {
302 env = create_update_message(ego); 303 env = create_update_message (ego);
303 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 304 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
304 } 305 }
305 env = GNUNET_MQ_msg_extra(ume, 0, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 306 env = GNUNET_MQ_msg_extra (ume, 0, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
306 ume->end_of_list = htons(GNUNET_YES); 307 ume->end_of_list = htons (GNUNET_YES);
307 ume->name_len = htons(0); 308 ume->name_len = htons (0);
308 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 309 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
309 GNUNET_SERVICE_client_continue(client); 310 GNUNET_SERVICE_client_continue (client);
310} 311}
311 312
312 313
@@ -319,9 +320,9 @@ handle_start_message(void *cls, const struct GNUNET_MessageHeader *message)
319 * @return #GNUNET_SYSERR if message was ill-formed 320 * @return #GNUNET_SYSERR if message was ill-formed
320 */ 321 */
321static int 322static int
322check_lookup_message(void *cls, const struct LookupMessage *message) 323check_lookup_message (void *cls, const struct LookupMessage *message)
323{ 324{
324 GNUNET_MQ_check_zero_termination(message); 325 GNUNET_MQ_check_zero_termination (message);
325 return GNUNET_OK; 326 return GNUNET_OK;
326} 327}
327 328
@@ -334,26 +335,26 @@ check_lookup_message(void *cls, const struct LookupMessage *message)
334 * @param message the message received 335 * @param message the message received
335 */ 336 */
336static void 337static void
337handle_lookup_message(void *cls, const struct LookupMessage *message) 338handle_lookup_message (void *cls, const struct LookupMessage *message)
338{ 339{
339 struct GNUNET_SERVICE_Client *client = cls; 340 struct GNUNET_SERVICE_Client *client = cls;
340 const char *name; 341 const char *name;
341 struct GNUNET_MQ_Envelope *env; 342 struct GNUNET_MQ_Envelope *env;
342 struct Ego *ego; 343 struct Ego *ego;
343 344
344 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received LOOKUP message from client\n"); 345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received LOOKUP message from client\n");
345 name = (const char *)&message[1]; 346 name = (const char *) &message[1];
346 for (ego = ego_head; NULL != ego; ego = ego->next) 347 for (ego = ego_head; NULL != ego; ego = ego->next)
347 { 348 {
348 if (0 != strcasecmp(name, ego->identifier)) 349 if (0 != strcasecmp (name, ego->identifier))
349 continue; 350 continue;
350 env = create_update_message(ego); 351 env = create_update_message (ego);
351 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 352 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
352 GNUNET_SERVICE_client_continue(client); 353 GNUNET_SERVICE_client_continue (client);
353 return; 354 return;
354 } 355 }
355 send_result_code(client, 0, "ego not found"); 356 send_result_code (client, 0, "ego not found");
356 GNUNET_SERVICE_client_continue(client); 357 GNUNET_SERVICE_client_continue (client);
357} 358}
358 359
359 360
@@ -366,9 +367,9 @@ handle_lookup_message(void *cls, const struct LookupMessage *message)
366 * @return #GNUNET_SYSERR if message was ill-formed 367 * @return #GNUNET_SYSERR if message was ill-formed
367 */ 368 */
368static int 369static int
369check_lookup_by_suffix_message(void *cls, const struct LookupMessage *message) 370check_lookup_by_suffix_message (void *cls, const struct LookupMessage *message)
370{ 371{
371 GNUNET_MQ_check_zero_termination(message); 372 GNUNET_MQ_check_zero_termination (message);
372 return GNUNET_OK; 373 return GNUNET_OK;
373} 374}
374 375
@@ -381,40 +382,40 @@ check_lookup_by_suffix_message(void *cls, const struct LookupMessage *message)
381 * @param message the message received 382 * @param message the message received
382 */ 383 */
383static void 384static void
384handle_lookup_by_suffix_message(void *cls, const struct LookupMessage *message) 385handle_lookup_by_suffix_message (void *cls, const struct LookupMessage *message)
385{ 386{
386 struct GNUNET_SERVICE_Client *client = cls; 387 struct GNUNET_SERVICE_Client *client = cls;
387 const char *name; 388 const char *name;
388 struct GNUNET_MQ_Envelope *env; 389 struct GNUNET_MQ_Envelope *env;
389 struct Ego *lprefix; 390 struct Ego *lprefix;
390 391
391 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
392 "Received LOOKUP_BY_SUFFIX message from client\n"); 393 "Received LOOKUP_BY_SUFFIX message from client\n");
393 name = (const char *)&message[1]; 394 name = (const char *) &message[1];
394 lprefix = NULL; 395 lprefix = NULL;
395 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next) 396 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
397 {
398 if ((strlen (ego->identifier) <= strlen (name)) &&
399 (0 == strcmp (ego->identifier,
400 &name[strlen (name) - strlen (ego->identifier)])) &&
401 ((strlen (name) == strlen (ego->identifier)) ||
402 ('.' == name[strlen (name) - strlen (ego->identifier) - 1])) &&
403 ((NULL == lprefix) ||
404 (strlen (ego->identifier) > strlen (lprefix->identifier))))
396 { 405 {
397 if ((strlen(ego->identifier) <= strlen(name)) && 406 /* found better match, update! */
398 (0 == strcmp(ego->identifier, 407 lprefix = ego;
399 &name[strlen(name) - strlen(ego->identifier)])) &&
400 ((strlen(name) == strlen(ego->identifier)) ||
401 ('.' == name[strlen(name) - strlen(ego->identifier) - 1])) &&
402 ((NULL == lprefix) ||
403 (strlen(ego->identifier) > strlen(lprefix->identifier))))
404 {
405 /* found better match, update! */
406 lprefix = ego;
407 }
408 } 408 }
409 }
409 if (NULL != lprefix) 410 if (NULL != lprefix)
410 { 411 {
411 env = create_update_message(lprefix); 412 env = create_update_message (lprefix);
412 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 413 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
413 GNUNET_SERVICE_client_continue(client); 414 GNUNET_SERVICE_client_continue (client);
414 return; 415 return;
415 } 416 }
416 send_result_code(client, 0, "ego not found"); 417 send_result_code (client, 0, "ego not found");
417 GNUNET_SERVICE_client_continue(client); 418 GNUNET_SERVICE_client_continue (client);
418} 419}
419 420
420 421
@@ -426,26 +427,26 @@ handle_lookup_by_suffix_message(void *cls, const struct LookupMessage *message)
426 * @return #GNUNET_OK if @a msg is well-formed 427 * @return #GNUNET_OK if @a msg is well-formed
427 */ 428 */
428static int 429static int
429check_get_default_message(void *cls, const struct GetDefaultMessage *msg) 430check_get_default_message (void *cls, const struct GetDefaultMessage *msg)
430{ 431{
431 uint16_t size; 432 uint16_t size;
432 uint16_t name_len; 433 uint16_t name_len;
433 const char *name; 434 const char *name;
434 435
435 size = ntohs(msg->header.size); 436 size = ntohs (msg->header.size);
436 if (size <= sizeof(struct GetDefaultMessage)) 437 if (size <= sizeof(struct GetDefaultMessage))
437 { 438 {
438 GNUNET_break(0); 439 GNUNET_break (0);
439 return GNUNET_SYSERR; 440 return GNUNET_SYSERR;
440 } 441 }
441 name = (const char *)&msg[1]; 442 name = (const char *) &msg[1];
442 name_len = ntohs(msg->name_len); 443 name_len = ntohs (msg->name_len);
443 if ((name_len + sizeof(struct GetDefaultMessage) != size) || 444 if ((name_len + sizeof(struct GetDefaultMessage) != size) ||
444 (0 != ntohs(msg->reserved)) || ('\0' != name[name_len - 1])) 445 (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
445 { 446 {
446 GNUNET_break(0); 447 GNUNET_break (0);
447 return GNUNET_SYSERR; 448 return GNUNET_SYSERR;
448 } 449 }
449 return GNUNET_OK; 450 return GNUNET_OK;
450} 451}
451 452
@@ -459,7 +460,7 @@ check_get_default_message(void *cls, const struct GetDefaultMessage *msg)
459 * @param message the message received 460 * @param message the message received
460 */ 461 */
461static void 462static void
462handle_get_default_message(void *cls, const struct GetDefaultMessage *gdm) 463handle_get_default_message (void *cls, const struct GetDefaultMessage *gdm)
463{ 464{
464 struct GNUNET_MQ_Envelope *env; 465 struct GNUNET_MQ_Envelope *env;
465 struct GNUNET_SERVICE_Client *client = cls; 466 struct GNUNET_SERVICE_Client *client = cls;
@@ -468,41 +469,41 @@ handle_get_default_message(void *cls, const struct GetDefaultMessage *gdm)
468 char *identifier; 469 char *identifier;
469 470
470 471
471 name = GNUNET_strdup((const char *)&gdm[1]); 472 name = GNUNET_strdup ((const char *) &gdm[1]);
472 GNUNET_STRINGS_utf8_tolower((const char *)&gdm[1], name); 473 GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
473 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
474 "Received GET_DEFAULT for service `%s' from client\n", 475 "Received GET_DEFAULT for service `%s' from client\n",
475 name); 476 name);
476 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(subsystem_cfg, 477 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
477 name, 478 name,
478 "DEFAULT_IDENTIFIER", 479 "DEFAULT_IDENTIFIER",
479 &identifier)) 480 &identifier))
480 { 481 {
481 send_result_code(client, 1, gettext_noop("no default known")); 482 send_result_code (client, 1, gettext_noop ("no default known"));
482 GNUNET_SERVICE_client_continue(client); 483 GNUNET_SERVICE_client_continue (client);
483 GNUNET_free(name); 484 GNUNET_free (name);
484 return; 485 return;
485 } 486 }
486 for (ego = ego_head; NULL != ego; ego = ego->next) 487 for (ego = ego_head; NULL != ego; ego = ego->next)
488 {
489 if (0 == strcmp (ego->identifier, identifier))
487 { 490 {
488 if (0 == strcmp(ego->identifier, identifier)) 491 env = create_set_default_message (ego, name);
489 { 492 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
490 env = create_set_default_message(ego, name); 493 GNUNET_SERVICE_client_continue (client);
491 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); 494 GNUNET_free (identifier);
492 GNUNET_SERVICE_client_continue(client); 495 GNUNET_free (name);
493 GNUNET_free(identifier); 496 return;
494 GNUNET_free(name);
495 return;
496 }
497 } 497 }
498 GNUNET_free(identifier); 498 }
499 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Failed to find ego `%s'\n", name); 499 GNUNET_free (identifier);
500 GNUNET_free(name); 500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to find ego `%s'\n", name);
501 send_result_code(client, 501 GNUNET_free (name);
502 1, 502 send_result_code (client,
503 gettext_noop( 503 1,
504 "default configured, but ego unknown (internal error)")); 504 gettext_noop (
505 GNUNET_SERVICE_client_continue(client); 505 "default configured, but ego unknown (internal error)"));
506 GNUNET_SERVICE_client_continue (client);
506} 507}
507 508
508 509
@@ -514,10 +515,10 @@ handle_get_default_message(void *cls, const struct GetDefaultMessage *gdm)
514 * @return 0 if the keys are equal 515 * @return 0 if the keys are equal
515 */ 516 */
516static int 517static int
517key_cmp(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1, 518key_cmp (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1,
518 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2) 519 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2)
519{ 520{
520 return GNUNET_memcmp(pk1, pk2); 521 return GNUNET_memcmp (pk1, pk2);
521} 522}
522 523
523/** 524/**
@@ -528,31 +529,31 @@ key_cmp(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1,
528 * @return #GNUNET_OK if @a msg is well-formed 529 * @return #GNUNET_OK if @a msg is well-formed
529 */ 530 */
530static int 531static int
531check_set_default_message(void *cls, const struct SetDefaultMessage *msg) 532check_set_default_message (void *cls, const struct SetDefaultMessage *msg)
532{ 533{
533 uint16_t size; 534 uint16_t size;
534 uint16_t name_len; 535 uint16_t name_len;
535 const char *str; 536 const char *str;
536 537
537 size = ntohs(msg->header.size); 538 size = ntohs (msg->header.size);
538 if (size <= sizeof(struct SetDefaultMessage)) 539 if (size <= sizeof(struct SetDefaultMessage))
539 { 540 {
540 GNUNET_break(0); 541 GNUNET_break (0);
541 return GNUNET_SYSERR; 542 return GNUNET_SYSERR;
542 } 543 }
543 name_len = ntohs(msg->name_len); 544 name_len = ntohs (msg->name_len);
544 GNUNET_break(0 == ntohs(msg->reserved)); 545 GNUNET_break (0 == ntohs (msg->reserved));
545 if (name_len + sizeof(struct SetDefaultMessage) != size) 546 if (name_len + sizeof(struct SetDefaultMessage) != size)
546 { 547 {
547 GNUNET_break(0); 548 GNUNET_break (0);
548 return GNUNET_SYSERR; 549 return GNUNET_SYSERR;
549 } 550 }
550 str = (const char *)&msg[1]; 551 str = (const char *) &msg[1];
551 if ('\0' != str[name_len - 1]) 552 if ('\0' != str[name_len - 1])
552 { 553 {
553 GNUNET_break(0); 554 GNUNET_break (0);
554 return GNUNET_SYSERR; 555 return GNUNET_SYSERR;
555 } 556 }
556 return GNUNET_OK; 557 return GNUNET_OK;
557} 558}
558 559
@@ -565,43 +566,43 @@ check_set_default_message(void *cls, const struct SetDefaultMessage *msg)
565 * @param message the message received 566 * @param message the message received
566 */ 567 */
567static void 568static void
568handle_set_default_message(void *cls, const struct SetDefaultMessage *sdm) 569handle_set_default_message (void *cls, const struct SetDefaultMessage *sdm)
569{ 570{
570 struct Ego *ego; 571 struct Ego *ego;
571 struct GNUNET_SERVICE_Client *client = cls; 572 struct GNUNET_SERVICE_Client *client = cls;
572 char *str; 573 char *str;
573 574
574 str = GNUNET_strdup((const char *)&sdm[1]); 575 str = GNUNET_strdup ((const char *) &sdm[1]);
575 GNUNET_STRINGS_utf8_tolower((const char *)&sdm[1], str); 576 GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str);
576 577
577 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
578 "Received SET_DEFAULT for service `%s' from client\n", 579 "Received SET_DEFAULT for service `%s' from client\n",
579 str); 580 str);
580 for (ego = ego_head; NULL != ego; ego = ego->next) 581 for (ego = ego_head; NULL != ego; ego = ego->next)
582 {
583 if (0 == key_cmp (ego->pk, &sdm->private_key))
581 { 584 {
582 if (0 == key_cmp(ego->pk, &sdm->private_key)) 585 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
583 { 586 str,
584 GNUNET_CONFIGURATION_set_value_string(subsystem_cfg, 587 "DEFAULT_IDENTIFIER",
585 str, 588 ego->identifier);
586 "DEFAULT_IDENTIFIER", 589 if (GNUNET_OK !=
587 ego->identifier); 590 GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
588 if (GNUNET_OK != 591 GNUNET_log (
589 GNUNET_CONFIGURATION_write(subsystem_cfg, subsystem_cfg_file)) 592 GNUNET_ERROR_TYPE_ERROR,
590 GNUNET_log( 593 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
591 GNUNET_ERROR_TYPE_ERROR, 594 subsystem_cfg_file);
592 _("Failed to write subsystem default identifier map to `%s'.\n"), 595 send_result_code (client, 0, NULL);
593 subsystem_cfg_file); 596 GNUNET_SERVICE_client_continue (client);
594 send_result_code(client, 0, NULL); 597 GNUNET_free (str);
595 GNUNET_SERVICE_client_continue(client); 598 return;
596 GNUNET_free(str);
597 return;
598 }
599 } 599 }
600 send_result_code(client, 600 }
601 1, 601 send_result_code (client,
602 _("Unknown ego specified for service (internal error)")); 602 1,
603 GNUNET_free(str); 603 _ ("Unknown ego specified for service (internal error)"));
604 GNUNET_SERVICE_client_continue(client); 604 GNUNET_free (str);
605 GNUNET_SERVICE_client_continue (client);
605} 606}
606 607
607 608
@@ -611,21 +612,21 @@ handle_set_default_message(void *cls, const struct SetDefaultMessage *sdm)
611 * @param ego ego to send the update for 612 * @param ego ego to send the update for
612 */ 613 */
613static void 614static void
614notify_listeners(struct Ego *ego) 615notify_listeners (struct Ego *ego)
615{ 616{
616 struct UpdateMessage *um; 617 struct UpdateMessage *um;
617 size_t name_len; 618 size_t name_len;
618 619
619 name_len = (NULL == ego->identifier) ? 0 : (strlen(ego->identifier) + 1); 620 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
620 um = GNUNET_malloc(sizeof(struct UpdateMessage) + name_len); 621 um = GNUNET_malloc (sizeof(struct UpdateMessage) + name_len);
621 um->header.type = htons(GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 622 um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
622 um->header.size = htons(sizeof(struct UpdateMessage) + name_len); 623 um->header.size = htons (sizeof(struct UpdateMessage) + name_len);
623 um->name_len = htons(name_len); 624 um->name_len = htons (name_len);
624 um->end_of_list = htons(GNUNET_NO); 625 um->end_of_list = htons (GNUNET_NO);
625 um->private_key = *ego->pk; 626 um->private_key = *ego->pk;
626 GNUNET_memcpy(&um[1], ego->identifier, name_len); 627 GNUNET_memcpy (&um[1], ego->identifier, name_len);
627 GNUNET_notification_context_broadcast(nc, &um->header, GNUNET_NO); 628 GNUNET_notification_context_broadcast (nc, &um->header, GNUNET_NO);
628 GNUNET_free(um); 629 GNUNET_free (um);
629} 630}
630 631
631/** 632/**
@@ -636,31 +637,31 @@ notify_listeners(struct Ego *ego)
636 * @return #GNUNET_OK if @a msg is well-formed 637 * @return #GNUNET_OK if @a msg is well-formed
637 */ 638 */
638static int 639static int
639check_create_message(void *cls, const struct CreateRequestMessage *msg) 640check_create_message (void *cls, const struct CreateRequestMessage *msg)
640{ 641{
641 uint16_t size; 642 uint16_t size;
642 uint16_t name_len; 643 uint16_t name_len;
643 const char *str; 644 const char *str;
644 645
645 size = ntohs(msg->header.size); 646 size = ntohs (msg->header.size);
646 if (size <= sizeof(struct CreateRequestMessage)) 647 if (size <= sizeof(struct CreateRequestMessage))
647 { 648 {
648 GNUNET_break(0); 649 GNUNET_break (0);
649 return GNUNET_SYSERR; 650 return GNUNET_SYSERR;
650 } 651 }
651 name_len = ntohs(msg->name_len); 652 name_len = ntohs (msg->name_len);
652 GNUNET_break(0 == ntohs(msg->reserved)); 653 GNUNET_break (0 == ntohs (msg->reserved));
653 if (name_len + sizeof(struct CreateRequestMessage) != size) 654 if (name_len + sizeof(struct CreateRequestMessage) != size)
654 { 655 {
655 GNUNET_break(0); 656 GNUNET_break (0);
656 return GNUNET_SYSERR; 657 return GNUNET_SYSERR;
657 } 658 }
658 str = (const char *)&msg[1]; 659 str = (const char *) &msg[1];
659 if ('\0' != str[name_len - 1]) 660 if ('\0' != str[name_len - 1])
660 { 661 {
661 GNUNET_break(0); 662 GNUNET_break (0);
662 return GNUNET_SYSERR; 663 return GNUNET_SYSERR;
663 } 664 }
664 return GNUNET_OK; 665 return GNUNET_OK;
665} 666}
666 667
@@ -673,55 +674,56 @@ check_create_message(void *cls, const struct CreateRequestMessage *msg)
673 * @param message the message received 674 * @param message the message received
674 */ 675 */
675static void 676static void
676handle_create_message(void *cls, const struct CreateRequestMessage *crm) 677handle_create_message (void *cls, const struct CreateRequestMessage *crm)
677{ 678{
678 struct GNUNET_SERVICE_Client *client = cls; 679 struct GNUNET_SERVICE_Client *client = cls;
679 struct Ego *ego; 680 struct Ego *ego;
680 char *str; 681 char *str;
681 char *fn; 682 char *fn;
682 683
683 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n"); 684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n");
684 str = GNUNET_strdup((const char *)&crm[1]); 685 str = GNUNET_strdup ((const char *) &crm[1]);
685 GNUNET_STRINGS_utf8_tolower((const char *)&crm[1], str); 686 GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str);
686 for (ego = ego_head; NULL != ego; ego = ego->next) 687 for (ego = ego_head; NULL != ego; ego = ego->next)
688 {
689 if (0 == strcmp (ego->identifier, str))
687 { 690 {
688 if (0 == strcmp(ego->identifier, str)) 691 send_result_code (client,
689 { 692 1,
690 send_result_code(client, 693 gettext_noop (
691 1, 694 "identifier already in use for another ego"));
692 gettext_noop( 695 GNUNET_SERVICE_client_continue (client);
693 "identifier already in use for another ego")); 696 GNUNET_free (str);
694 GNUNET_SERVICE_client_continue(client); 697 return;
695 GNUNET_free(str);
696 return;
697 }
698 } 698 }
699 ego = GNUNET_new(struct Ego); 699 }
700 ego->pk = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); 700 ego = GNUNET_new (struct Ego);
701 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
701 *ego->pk = crm->private_key; 702 *ego->pk = crm->private_key;
702 ego->identifier = GNUNET_strdup(str); 703 ego->identifier = GNUNET_strdup (str);
703 GNUNET_CONTAINER_DLL_insert(ego_head, ego_tail, ego); 704 GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego);
704 send_result_code(client, 0, NULL); 705 send_result_code (client, 0, NULL);
705 fn = get_ego_filename(ego); 706 fn = get_ego_filename (ego);
706 (void)GNUNET_DISK_directory_create_for_file(fn); 707 (void) GNUNET_DISK_directory_create_for_file (fn);
707 if (sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey) != 708 if (sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey) !=
708 GNUNET_DISK_fn_write(fn, 709 GNUNET_DISK_fn_write (fn,
709 &crm->private_key, 710 &crm->private_key,
710 sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey), 711 sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey),
711 GNUNET_DISK_PERM_USER_READ | 712 GNUNET_DISK_PERM_USER_READ
712 GNUNET_DISK_PERM_USER_WRITE)) 713 | GNUNET_DISK_PERM_USER_WRITE))
713 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "write", fn); 714 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
714 GNUNET_free(fn); 715 GNUNET_free (fn);
715 GNUNET_free(str); 716 GNUNET_free (str);
716 notify_listeners(ego); 717 notify_listeners (ego);
717 GNUNET_SERVICE_client_continue(client); 718 GNUNET_SERVICE_client_continue (client);
718} 719}
719 720
720 721
721/** 722/**
722 * Closure for 'handle_ego_rename'. 723 * Closure for 'handle_ego_rename'.
723 */ 724 */
724struct RenameContext { 725struct RenameContext
726{
725 /** 727 /**
726 * Old name. 728 * Old name.
727 */ 729 */
@@ -741,26 +743,26 @@ struct RenameContext {
741 * @param section a section in the configuration to process 743 * @param section a section in the configuration to process
742 */ 744 */
743static void 745static void
744handle_ego_rename(void *cls, const char *section) 746handle_ego_rename (void *cls, const char *section)
745{ 747{
746 struct RenameContext *rc = cls; 748 struct RenameContext *rc = cls;
747 char *id; 749 char *id;
748 750
749 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(subsystem_cfg, 751 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
750 section, 752 section,
751 "DEFAULT_IDENTIFIER", 753 "DEFAULT_IDENTIFIER",
752 &id)) 754 &id))
753 return; 755 return;
754 if (0 != strcmp(id, rc->old_name)) 756 if (0 != strcmp (id, rc->old_name))
755 { 757 {
756 GNUNET_free(id); 758 GNUNET_free (id);
757 return; 759 return;
758 } 760 }
759 GNUNET_CONFIGURATION_set_value_string(subsystem_cfg, 761 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
760 section, 762 section,
761 "DEFAULT_IDENTIFIER", 763 "DEFAULT_IDENTIFIER",
762 rc->new_name); 764 rc->new_name);
763 GNUNET_free(id); 765 GNUNET_free (id);
764} 766}
765 767
766/** 768/**
@@ -771,7 +773,7 @@ handle_ego_rename(void *cls, const char *section)
771 * @return #GNUNET_OK if @a msg is well-formed 773 * @return #GNUNET_OK if @a msg is well-formed
772 */ 774 */
773static int 775static int
774check_rename_message(void *cls, const struct RenameMessage *msg) 776check_rename_message (void *cls, const struct RenameMessage *msg)
775{ 777{
776 uint16_t size; 778 uint16_t size;
777 uint16_t old_name_len; 779 uint16_t old_name_len;
@@ -779,23 +781,23 @@ check_rename_message(void *cls, const struct RenameMessage *msg)
779 const char *old_name; 781 const char *old_name;
780 const char *new_name; 782 const char *new_name;
781 783
782 size = ntohs(msg->header.size); 784 size = ntohs (msg->header.size);
783 if (size <= sizeof(struct RenameMessage)) 785 if (size <= sizeof(struct RenameMessage))
784 { 786 {
785 GNUNET_break(0); 787 GNUNET_break (0);
786 return GNUNET_SYSERR; 788 return GNUNET_SYSERR;
787 } 789 }
788 old_name_len = ntohs(msg->old_name_len); 790 old_name_len = ntohs (msg->old_name_len);
789 new_name_len = ntohs(msg->new_name_len); 791 new_name_len = ntohs (msg->new_name_len);
790 old_name = (const char *)&msg[1]; 792 old_name = (const char *) &msg[1];
791 new_name = &old_name[old_name_len]; 793 new_name = &old_name[old_name_len];
792 if ((old_name_len + new_name_len + sizeof(struct RenameMessage) != size) || 794 if ((old_name_len + new_name_len + sizeof(struct RenameMessage) != size) ||
793 ('\0' != old_name[old_name_len - 1]) || 795 ('\0' != old_name[old_name_len - 1]) ||
794 ('\0' != new_name[new_name_len - 1])) 796 ('\0' != new_name[new_name_len - 1]))
795 { 797 {
796 GNUNET_break(0); 798 GNUNET_break (0);
797 return GNUNET_SYSERR; 799 return GNUNET_SYSERR;
798 } 800 }
799 801
800 return GNUNET_OK; 802 return GNUNET_OK;
801} 803}
@@ -810,7 +812,7 @@ check_rename_message(void *cls, const struct RenameMessage *msg)
810 * @param message the message received 812 * @param message the message received
811 */ 813 */
812static void 814static void
813handle_rename_message(void *cls, const struct RenameMessage *rm) 815handle_rename_message (void *cls, const struct RenameMessage *rm)
814{ 816{
815 uint16_t old_name_len; 817 uint16_t old_name_len;
816 struct Ego *ego; 818 struct Ego *ego;
@@ -822,65 +824,65 @@ handle_rename_message(void *cls, const struct RenameMessage *rm)
822 char *fn_new; 824 char *fn_new;
823 const char *old_name_tmp; 825 const char *old_name_tmp;
824 826
825 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n"); 827 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n");
826 old_name_len = ntohs(rm->old_name_len); 828 old_name_len = ntohs (rm->old_name_len);
827 old_name_tmp = (const char *)&rm[1]; 829 old_name_tmp = (const char *) &rm[1];
828 old_name = GNUNET_strdup(old_name_tmp); 830 old_name = GNUNET_strdup (old_name_tmp);
829 GNUNET_STRINGS_utf8_tolower(old_name_tmp, old_name); 831 GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
830 new_name = GNUNET_strdup(&old_name_tmp[old_name_len]); 832 new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
831 GNUNET_STRINGS_utf8_tolower(&old_name_tmp[old_name_len], new_name); 833 GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], new_name);
832 834
833 /* check if new name is already in use */ 835 /* check if new name is already in use */
834 for (ego = ego_head; NULL != ego; ego = ego->next) 836 for (ego = ego_head; NULL != ego; ego = ego->next)
837 {
838 if (0 == strcmp (ego->identifier, new_name))
835 { 839 {
836 if (0 == strcmp(ego->identifier, new_name)) 840 send_result_code (client, 1, gettext_noop ("target name already exists"));
837 { 841 GNUNET_SERVICE_client_continue (client);
838 send_result_code(client, 1, gettext_noop("target name already exists")); 842 GNUNET_free (old_name);
839 GNUNET_SERVICE_client_continue(client); 843 GNUNET_free (new_name);
840 GNUNET_free(old_name); 844 return;
841 GNUNET_free(new_name);
842 return;
843 }
844 } 845 }
846 }
845 847
846 /* locate old name and, if found, perform rename */ 848 /* locate old name and, if found, perform rename */
847 for (ego = ego_head; NULL != ego; ego = ego->next) 849 for (ego = ego_head; NULL != ego; ego = ego->next)
850 {
851 if (0 == strcmp (ego->identifier, old_name))
848 { 852 {
849 if (0 == strcmp(ego->identifier, old_name)) 853 fn_old = get_ego_filename (ego);
850 { 854 GNUNET_free (ego->identifier);
851 fn_old = get_ego_filename(ego); 855 rename_ctx.old_name = old_name;
852 GNUNET_free(ego->identifier); 856 rename_ctx.new_name = new_name;
853 rename_ctx.old_name = old_name; 857 GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg,
854 rename_ctx.new_name = new_name; 858 &handle_ego_rename,
855 GNUNET_CONFIGURATION_iterate_sections(subsystem_cfg, 859 &rename_ctx);
856 &handle_ego_rename, 860 if (GNUNET_OK !=
857 &rename_ctx); 861 GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
858 if (GNUNET_OK != 862 GNUNET_log (
859 GNUNET_CONFIGURATION_write(subsystem_cfg, subsystem_cfg_file)) 863 GNUNET_ERROR_TYPE_ERROR,
860 GNUNET_log( 864 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
861 GNUNET_ERROR_TYPE_ERROR, 865 subsystem_cfg_file);
862 _("Failed to write subsystem default identifier map to `%s'.\n"), 866 ego->identifier = GNUNET_strdup (new_name);
863 subsystem_cfg_file); 867 fn_new = get_ego_filename (ego);
864 ego->identifier = GNUNET_strdup(new_name); 868 if (0 != rename (fn_old, fn_new))
865 fn_new = get_ego_filename(ego); 869 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old);
866 if (0 != rename(fn_old, fn_new)) 870 GNUNET_free (fn_old);
867 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); 871 GNUNET_free (fn_new);
868 GNUNET_free(fn_old); 872 GNUNET_free (old_name);
869 GNUNET_free(fn_new); 873 GNUNET_free (new_name);
870 GNUNET_free(old_name); 874 notify_listeners (ego);
871 GNUNET_free(new_name); 875 send_result_code (client, 0, NULL);
872 notify_listeners(ego); 876 GNUNET_SERVICE_client_continue (client);
873 send_result_code(client, 0, NULL); 877 return;
874 GNUNET_SERVICE_client_continue(client);
875 return;
876 }
877 } 878 }
879 }
878 880
879 /* failed to locate old name */ 881 /* failed to locate old name */
880 send_result_code(client, 1, gettext_noop("no matching ego found")); 882 send_result_code (client, 1, gettext_noop ("no matching ego found"));
881 GNUNET_free(old_name); 883 GNUNET_free (old_name);
882 GNUNET_free(new_name); 884 GNUNET_free (new_name);
883 GNUNET_SERVICE_client_continue(client); 885 GNUNET_SERVICE_client_continue (client);
884} 886}
885 887
886 888
@@ -892,26 +894,26 @@ handle_rename_message(void *cls, const struct RenameMessage *rm)
892 * @param section a section in the configuration to process 894 * @param section a section in the configuration to process
893 */ 895 */
894static void 896static void
895handle_ego_delete(void *cls, const char *section) 897handle_ego_delete (void *cls, const char *section)
896{ 898{
897 const char *identifier = cls; 899 const char *identifier = cls;
898 char *id; 900 char *id;
899 901
900 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(subsystem_cfg, 902 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
901 section, 903 section,
902 "DEFAULT_IDENTIFIER", 904 "DEFAULT_IDENTIFIER",
903 &id)) 905 &id))
904 return; 906 return;
905 if (0 != strcmp(id, identifier)) 907 if (0 != strcmp (id, identifier))
906 { 908 {
907 GNUNET_free(id); 909 GNUNET_free (id);
908 return; 910 return;
909 } 911 }
910 GNUNET_CONFIGURATION_set_value_string(subsystem_cfg, 912 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
911 section, 913 section,
912 "DEFAULT_IDENTIFIER", 914 "DEFAULT_IDENTIFIER",
913 NULL); 915 NULL);
914 GNUNET_free(id); 916 GNUNET_free (id);
915} 917}
916 918
917/** 919/**
@@ -922,26 +924,26 @@ handle_ego_delete(void *cls, const char *section)
922 * @return #GNUNET_OK if @a msg is well-formed 924 * @return #GNUNET_OK if @a msg is well-formed
923 */ 925 */
924static int 926static int
925check_delete_message(void *cls, const struct DeleteMessage *msg) 927check_delete_message (void *cls, const struct DeleteMessage *msg)
926{ 928{
927 uint16_t size; 929 uint16_t size;
928 uint16_t name_len; 930 uint16_t name_len;
929 const char *name; 931 const char *name;
930 932
931 size = ntohs(msg->header.size); 933 size = ntohs (msg->header.size);
932 if (size <= sizeof(struct DeleteMessage)) 934 if (size <= sizeof(struct DeleteMessage))
933 { 935 {
934 GNUNET_break(0); 936 GNUNET_break (0);
935 return GNUNET_SYSERR; 937 return GNUNET_SYSERR;
936 } 938 }
937 name = (const char *)&msg[1]; 939 name = (const char *) &msg[1];
938 name_len = ntohs(msg->name_len); 940 name_len = ntohs (msg->name_len);
939 if ((name_len + sizeof(struct DeleteMessage) != size) || 941 if ((name_len + sizeof(struct DeleteMessage) != size) ||
940 (0 != ntohs(msg->reserved)) || ('\0' != name[name_len - 1])) 942 (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
941 { 943 {
942 GNUNET_break(0); 944 GNUNET_break (0);
943 return GNUNET_SYSERR; 945 return GNUNET_SYSERR;
944 } 946 }
945 return GNUNET_OK; 947 return GNUNET_OK;
946} 948}
947 949
@@ -955,50 +957,50 @@ check_delete_message(void *cls, const struct DeleteMessage *msg)
955 * @param message the message received 957 * @param message the message received
956 */ 958 */
957static void 959static void
958handle_delete_message(void *cls, const struct DeleteMessage *dm) 960handle_delete_message (void *cls, const struct DeleteMessage *dm)
959{ 961{
960 struct Ego *ego; 962 struct Ego *ego;
961 char *name; 963 char *name;
962 char *fn; 964 char *fn;
963 struct GNUNET_SERVICE_Client *client = cls; 965 struct GNUNET_SERVICE_Client *client = cls;
964 966
965 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received DELETE message from client\n"); 967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received DELETE message from client\n");
966 name = GNUNET_strdup((const char *)&dm[1]); 968 name = GNUNET_strdup ((const char *) &dm[1]);
967 GNUNET_STRINGS_utf8_tolower((const char *)&dm[1], name); 969 GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
968 970
969 for (ego = ego_head; NULL != ego; ego = ego->next) 971 for (ego = ego_head; NULL != ego; ego = ego->next)
972 {
973 if (0 == strcmp (ego->identifier, name))
970 { 974 {
971 if (0 == strcmp(ego->identifier, name)) 975 GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, ego);
972 { 976 GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg,
973 GNUNET_CONTAINER_DLL_remove(ego_head, ego_tail, ego); 977 &handle_ego_delete,
974 GNUNET_CONFIGURATION_iterate_sections(subsystem_cfg, 978 ego->identifier);
975 &handle_ego_delete, 979 if (GNUNET_OK !=
976 ego->identifier); 980 GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
977 if (GNUNET_OK != 981 GNUNET_log (
978 GNUNET_CONFIGURATION_write(subsystem_cfg, subsystem_cfg_file)) 982 GNUNET_ERROR_TYPE_ERROR,
979 GNUNET_log( 983 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
980 GNUNET_ERROR_TYPE_ERROR, 984 subsystem_cfg_file);
981 _("Failed to write subsystem default identifier map to `%s'.\n"), 985 fn = get_ego_filename (ego);
982 subsystem_cfg_file); 986 if (0 != unlink (fn))
983 fn = get_ego_filename(ego); 987 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
984 if (0 != unlink(fn)) 988 GNUNET_free (fn);
985 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_WARNING, "unlink", fn); 989 GNUNET_free (ego->identifier);
986 GNUNET_free(fn); 990 ego->identifier = NULL;
987 GNUNET_free(ego->identifier); 991 notify_listeners (ego);
988 ego->identifier = NULL; 992 GNUNET_free (ego->pk);
989 notify_listeners(ego); 993 GNUNET_free (ego);
990 GNUNET_free(ego->pk); 994 GNUNET_free (name);
991 GNUNET_free(ego); 995 send_result_code (client, 0, NULL);
992 GNUNET_free(name); 996 GNUNET_SERVICE_client_continue (client);
993 send_result_code(client, 0, NULL); 997 return;
994 GNUNET_SERVICE_client_continue(client);
995 return;
996 }
997 } 998 }
999 }
998 1000
999 send_result_code(client, 1, gettext_noop("no matching ego found")); 1001 send_result_code (client, 1, gettext_noop ("no matching ego found"));
1000 GNUNET_free(name); 1002 GNUNET_free (name);
1001 GNUNET_SERVICE_client_continue(client); 1003 GNUNET_SERVICE_client_continue (client);
1002} 1004}
1003 1005
1004 1006
@@ -1013,30 +1015,30 @@ handle_delete_message(void *cls, const struct DeleteMessage *dm)
1013 * #GNUNET_SYSERR to abort iteration with error! 1015 * #GNUNET_SYSERR to abort iteration with error!
1014 */ 1016 */
1015static int 1017static int
1016process_ego_file(void *cls, const char *filename) 1018process_ego_file (void *cls, const char *filename)
1017{ 1019{
1018 struct Ego *ego; 1020 struct Ego *ego;
1019 const char *fn; 1021 const char *fn;
1020 1022
1021 fn = strrchr(filename, (int)DIR_SEPARATOR); 1023 fn = strrchr (filename, (int) DIR_SEPARATOR);
1022 if (NULL == fn) 1024 if (NULL == fn)
1023 { 1025 {
1024 GNUNET_break(0); 1026 GNUNET_break (0);
1025 return GNUNET_OK; 1027 return GNUNET_OK;
1026 } 1028 }
1027 ego = GNUNET_new(struct Ego); 1029 ego = GNUNET_new (struct Ego);
1028 ego->pk = GNUNET_CRYPTO_ecdsa_key_create_from_file(filename); 1030 ego->pk = GNUNET_CRYPTO_ecdsa_key_create_from_file (filename);
1029 if (NULL == ego->pk) 1031 if (NULL == ego->pk)
1030 { 1032 {
1031 GNUNET_free(ego); 1033 GNUNET_free (ego);
1032 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1034 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1033 _("Failed to parse ego information in `%s'\n"), 1035 _ ("Failed to parse ego information in `%s'\n"),
1034 filename); 1036 filename);
1035 return GNUNET_OK; 1037 return GNUNET_OK;
1036 } 1038 }
1037 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Loaded ego `%s'\n", fn + 1); 1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded ego `%s'\n", fn + 1);
1038 ego->identifier = GNUNET_strdup(fn + 1); 1040 ego->identifier = GNUNET_strdup (fn + 1);
1039 GNUNET_CONTAINER_DLL_insert(ego_head, ego_tail, ego); 1041 GNUNET_CONTAINER_DLL_insert (ego_head, ego_tail, ego);
1040 return GNUNET_OK; 1042 return GNUNET_OK;
1041} 1043}
1042 1044
@@ -1049,103 +1051,103 @@ process_ego_file(void *cls, const char *filename)
1049 * @param c configuration to use 1051 * @param c configuration to use
1050 */ 1052 */
1051static void 1053static void
1052run(void *cls, 1054run (void *cls,
1053 const struct GNUNET_CONFIGURATION_Handle *c, 1055 const struct GNUNET_CONFIGURATION_Handle *c,
1054 struct GNUNET_SERVICE_Handle *service) 1056 struct GNUNET_SERVICE_Handle *service)
1055{ 1057{
1056 cfg = c; 1058 cfg = c;
1057 nc = GNUNET_notification_context_create(1); 1059 nc = GNUNET_notification_context_create (1);
1058 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg, 1060 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
1059 "identity", 1061 "identity",
1060 "EGODIR", 1062 "EGODIR",
1061 &ego_directory)) 1063 &ego_directory))
1062 { 1064 {
1063 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, "identity", "EGODIR"); 1065 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "EGODIR");
1064 GNUNET_SCHEDULER_shutdown(); 1066 GNUNET_SCHEDULER_shutdown ();
1065 return; 1067 return;
1066 } 1068 }
1067 if (GNUNET_OK != 1069 if (GNUNET_OK !=
1068 GNUNET_CONFIGURATION_get_value_filename(cfg, 1070 GNUNET_CONFIGURATION_get_value_filename (cfg,
1069 "identity", 1071 "identity",
1070 "SUBSYSTEM_CFG", 1072 "SUBSYSTEM_CFG",
1071 &subsystem_cfg_file)) 1073 &subsystem_cfg_file))
1072 { 1074 {
1073 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, 1075 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
1074 "identity", 1076 "identity",
1075 "SUBSYSTEM_CFG"); 1077 "SUBSYSTEM_CFG");
1076 GNUNET_SCHEDULER_shutdown(); 1078 GNUNET_SCHEDULER_shutdown ();
1077 return; 1079 return;
1078 } 1080 }
1079 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1080 "Loading subsystem configuration `%s'\n", 1082 "Loading subsystem configuration `%s'\n",
1081 subsystem_cfg_file); 1083 subsystem_cfg_file);
1082 subsystem_cfg = GNUNET_CONFIGURATION_create(); 1084 subsystem_cfg = GNUNET_CONFIGURATION_create ();
1083 if ((GNUNET_YES == GNUNET_DISK_file_test(subsystem_cfg_file)) && 1085 if ((GNUNET_YES == GNUNET_DISK_file_test (subsystem_cfg_file)) &&
1084 (GNUNET_OK != 1086 (GNUNET_OK !=
1085 GNUNET_CONFIGURATION_parse(subsystem_cfg, subsystem_cfg_file))) 1087 GNUNET_CONFIGURATION_parse (subsystem_cfg, subsystem_cfg_file)))
1086 { 1088 {
1087 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1089 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1088 _( 1090 _ (
1089 "Failed to parse subsystem identity configuration file `%s'\n"), 1091 "Failed to parse subsystem identity configuration file `%s'\n"),
1090 subsystem_cfg_file); 1092 subsystem_cfg_file);
1091 GNUNET_SCHEDULER_shutdown(); 1093 GNUNET_SCHEDULER_shutdown ();
1092 return; 1094 return;
1093 } 1095 }
1094 stats = GNUNET_STATISTICS_create("identity", cfg); 1096 stats = GNUNET_STATISTICS_create ("identity", cfg);
1095 if (GNUNET_OK != GNUNET_DISK_directory_create(ego_directory)) 1097 if (GNUNET_OK != GNUNET_DISK_directory_create (ego_directory))
1096 { 1098 {
1097 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1099 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1098 _("Failed to create directory `%s' for storing egos\n"), 1100 _ ("Failed to create directory `%s' for storing egos\n"),
1099 ego_directory); 1101 ego_directory);
1100 } 1102 }
1101 GNUNET_DISK_directory_scan(ego_directory, &process_ego_file, NULL); 1103 GNUNET_DISK_directory_scan (ego_directory, &process_ego_file, NULL);
1102 GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); 1104 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1103} 1105}
1104 1106
1105 1107
1106/** 1108/**
1107 * Define "main" method using service macro. 1109 * Define "main" method using service macro.
1108 */ 1110 */
1109GNUNET_SERVICE_MAIN( 1111GNUNET_SERVICE_MAIN (
1110 "identity", 1112 "identity",
1111 GNUNET_SERVICE_OPTION_NONE, 1113 GNUNET_SERVICE_OPTION_NONE,
1112 &run, 1114 &run,
1113 &client_connect_cb, 1115 &client_connect_cb,
1114 &client_disconnect_cb, 1116 &client_disconnect_cb,
1115 NULL, 1117 NULL,
1116 GNUNET_MQ_hd_fixed_size(start_message, 1118 GNUNET_MQ_hd_fixed_size (start_message,
1117 GNUNET_MESSAGE_TYPE_IDENTITY_START, 1119 GNUNET_MESSAGE_TYPE_IDENTITY_START,
1118 struct GNUNET_MessageHeader, 1120 struct GNUNET_MessageHeader,
1119 NULL), 1121 NULL),
1120 GNUNET_MQ_hd_var_size(lookup_message, 1122 GNUNET_MQ_hd_var_size (lookup_message,
1121 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, 1123 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP,
1122 struct LookupMessage, 1124 struct LookupMessage,
1123 NULL), 1125 NULL),
1124 GNUNET_MQ_hd_var_size(lookup_by_suffix_message, 1126 GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
1125 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, 1127 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX,
1126 struct LookupMessage, 1128 struct LookupMessage,
1127 NULL), 1129 NULL),
1128 GNUNET_MQ_hd_var_size(get_default_message, 1130 GNUNET_MQ_hd_var_size (get_default_message,
1129 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, 1131 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
1130 struct GetDefaultMessage, 1132 struct GetDefaultMessage,
1131 NULL), 1133 NULL),
1132 GNUNET_MQ_hd_var_size(set_default_message, 1134 GNUNET_MQ_hd_var_size (set_default_message,
1133 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, 1135 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
1134 struct SetDefaultMessage, 1136 struct SetDefaultMessage,
1135 NULL), 1137 NULL),
1136 GNUNET_MQ_hd_var_size(create_message, 1138 GNUNET_MQ_hd_var_size (create_message,
1137 GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, 1139 GNUNET_MESSAGE_TYPE_IDENTITY_CREATE,
1138 struct CreateRequestMessage, 1140 struct CreateRequestMessage,
1139 NULL), 1141 NULL),
1140 GNUNET_MQ_hd_var_size(rename_message, 1142 GNUNET_MQ_hd_var_size (rename_message,
1141 GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, 1143 GNUNET_MESSAGE_TYPE_IDENTITY_RENAME,
1142 struct RenameMessage, 1144 struct RenameMessage,
1143 NULL), 1145 NULL),
1144 GNUNET_MQ_hd_var_size(delete_message, 1146 GNUNET_MQ_hd_var_size (delete_message,
1145 GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, 1147 GNUNET_MESSAGE_TYPE_IDENTITY_DELETE,
1146 struct DeleteMessage, 1148 struct DeleteMessage,
1147 NULL), 1149 NULL),
1148 GNUNET_MQ_handler_end()); 1150 GNUNET_MQ_handler_end ());
1149 1151
1150 1152
1151/* end of gnunet-service-identity.c */ 1153/* end of gnunet-service-identity.c */
diff --git a/src/identity/identity.h b/src/identity/identity.h
index 6a4090ad8..b3c03d1ce 100644
--- a/src/identity/identity.h
+++ b/src/identity/identity.h
@@ -39,7 +39,8 @@ GNUNET_NETWORK_STRUCT_BEGIN
39 * GET_DEFAULT maybe answered with this message on failure; 39 * GET_DEFAULT maybe answered with this message on failure;
40 * CREATE and RENAME will always be answered with this message. 40 * CREATE and RENAME will always be answered with this message.
41 */ 41 */
42struct ResultCodeMessage { 42struct ResultCodeMessage
43{
43 /** 44 /**
44 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE 45 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
45 */ 46 */
@@ -58,7 +59,8 @@ struct ResultCodeMessage {
58/** 59/**
59 * Client informs service about desire to lookup a (single) pseudonym. 60 * Client informs service about desire to lookup a (single) pseudonym.
60 */ 61 */
61struct LookupMessage { 62struct LookupMessage
63{
62 /** 64 /**
63 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP or 65 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP or
64 * #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX 66 * #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
@@ -72,7 +74,8 @@ struct LookupMessage {
72/** 74/**
73 * Service informs client about status of a pseudonym. 75 * Service informs client about status of a pseudonym.
74 */ 76 */
75struct UpdateMessage { 77struct UpdateMessage
78{
76 /** 79 /**
77 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE 80 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
78 */ 81 */
@@ -102,7 +105,8 @@ struct UpdateMessage {
102 * Client requests knowledge about default identity for 105 * Client requests knowledge about default identity for
103 * a subsystem from identity service. 106 * a subsystem from identity service.
104 */ 107 */
105struct GetDefaultMessage { 108struct GetDefaultMessage
109{
106 /** 110 /**
107 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT 111 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
108 */ 112 */
@@ -127,7 +131,8 @@ struct GetDefaultMessage {
127 * Used from service to client as a result to the GET_DEFAULT 131 * Used from service to client as a result to the GET_DEFAULT
128 * message, used from client to service to SET_DEFAULT. 132 * message, used from client to service to SET_DEFAULT.
129 */ 133 */
130struct SetDefaultMessage { 134struct SetDefaultMessage
135{
131 /** 136 /**
132 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT 137 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
133 */ 138 */
@@ -156,7 +161,8 @@ struct SetDefaultMessage {
156 * Client requests creation of an identity. Service 161 * Client requests creation of an identity. Service
157 * will respond with a result code. 162 * will respond with a result code.
158 */ 163 */
159struct CreateRequestMessage { 164struct CreateRequestMessage
165{
160 /** 166 /**
161 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_CREATE 167 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
162 */ 168 */
@@ -185,7 +191,8 @@ struct CreateRequestMessage {
185 * Client requests renaming of an identity. Service 191 * Client requests renaming of an identity. Service
186 * will respond with a result code. 192 * will respond with a result code.
187 */ 193 */
188struct RenameMessage { 194struct RenameMessage
195{
189 /** 196 /**
190 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RENAME 197 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
191 */ 198 */
@@ -210,7 +217,8 @@ struct RenameMessage {
210 * Client requests deletion of an identity. Service 217 * Client requests deletion of an identity. Service
211 * will respond with a result code. 218 * will respond with a result code.
212 */ 219 */
213struct DeleteMessage { 220struct DeleteMessage
221{
214 /** 222 /**
215 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_DELETE 223 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
216 */ 224 */
@@ -234,7 +242,8 @@ GNUNET_NETWORK_STRUCT_END
234/** 242/**
235 * Handle for an ego. 243 * Handle for an ego.
236 */ 244 */
237struct GNUNET_IDENTITY_Ego { 245struct GNUNET_IDENTITY_Ego
246{
238 /** 247 /**
239 * Private key associated with this ego. 248 * Private key associated with this ego.
240 */ 249 */
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 530ee2d13..42e25c11d 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -30,13 +30,14 @@
30#include "gnunet_identity_service.h" 30#include "gnunet_identity_service.h"
31#include "identity.h" 31#include "identity.h"
32 32
33#define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) 33#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
34 34
35 35
36/** 36/**
37 * Handle for an operation with the identity service. 37 * Handle for an operation with the identity service.
38 */ 38 */
39struct GNUNET_IDENTITY_Operation { 39struct GNUNET_IDENTITY_Operation
40{
40 /** 41 /**
41 * Main identity handle. 42 * Main identity handle.
42 */ 43 */
@@ -91,7 +92,8 @@ struct GNUNET_IDENTITY_Operation {
91/** 92/**
92 * Handle for the service. 93 * Handle for the service.
93 */ 94 */
94struct GNUNET_IDENTITY_Handle { 95struct GNUNET_IDENTITY_Handle
96{
95 /** 97 /**
96 * Configuration to use. 98 * Configuration to use.
97 */ 99 */
@@ -151,7 +153,7 @@ struct GNUNET_IDENTITY_Handle {
151 * @return handle for the anonymous user, must not be freed 153 * @return handle for the anonymous user, must not be freed
152 */ 154 */
153const struct GNUNET_IDENTITY_Ego * 155const struct GNUNET_IDENTITY_Ego *
154GNUNET_IDENTITY_ego_get_anonymous() 156GNUNET_IDENTITY_ego_get_anonymous ()
155{ 157{
156 static struct GNUNET_IDENTITY_Ego anon; 158 static struct GNUNET_IDENTITY_Ego anon;
157 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 159 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
@@ -159,9 +161,9 @@ GNUNET_IDENTITY_ego_get_anonymous()
159 if (NULL != anon.pk) 161 if (NULL != anon.pk)
160 return &anon; 162 return &anon;
161 anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) 163 anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)
162 GNUNET_CRYPTO_ecdsa_key_get_anonymous(); 164 GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
163 GNUNET_CRYPTO_ecdsa_key_get_public(anon.pk, &pub); 165 GNUNET_CRYPTO_ecdsa_key_get_public (anon.pk, &pub);
164 GNUNET_CRYPTO_hash(&pub, sizeof(pub), &anon.id); 166 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &anon.id);
165 return &anon; 167 return &anon;
166} 168}
167 169
@@ -172,7 +174,7 @@ GNUNET_IDENTITY_ego_get_anonymous()
172 * @param cls handle to the identity service. 174 * @param cls handle to the identity service.
173 */ 175 */
174static void 176static void
175reconnect(void *cls); 177reconnect (void *cls);
176 178
177 179
178/** 180/**
@@ -184,18 +186,18 @@ reconnect(void *cls);
184 * @return #GNUNET_OK (continue to iterate) 186 * @return #GNUNET_OK (continue to iterate)
185 */ 187 */
186static int 188static int
187free_ego(void *cls, const struct GNUNET_HashCode *key, void *value) 189free_ego (void *cls, const struct GNUNET_HashCode *key, void *value)
188{ 190{
189 struct GNUNET_IDENTITY_Handle *h = cls; 191 struct GNUNET_IDENTITY_Handle *h = cls;
190 struct GNUNET_IDENTITY_Ego *ego = value; 192 struct GNUNET_IDENTITY_Ego *ego = value;
191 193
192 if (NULL != h->cb) 194 if (NULL != h->cb)
193 h->cb(h->cb_cls, ego, &ego->ctx, NULL); 195 h->cb (h->cb_cls, ego, &ego->ctx, NULL);
194 GNUNET_free(ego->pk); 196 GNUNET_free (ego->pk);
195 GNUNET_free(ego->name); 197 GNUNET_free (ego->name);
196 GNUNET_assert(GNUNET_YES == 198 GNUNET_assert (GNUNET_YES ==
197 GNUNET_CONTAINER_multihashmap_remove(h->egos, key, value)); 199 GNUNET_CONTAINER_multihashmap_remove (h->egos, key, value));
198 GNUNET_free(ego); 200 GNUNET_free (ego);
199 return GNUNET_OK; 201 return GNUNET_OK;
200} 202}
201 203
@@ -206,38 +208,38 @@ free_ego(void *cls, const struct GNUNET_HashCode *key, void *value)
206 * @param h transport service to reconnect 208 * @param h transport service to reconnect
207 */ 209 */
208static void 210static void
209reschedule_connect(struct GNUNET_IDENTITY_Handle *h) 211reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
210{ 212{
211 struct GNUNET_IDENTITY_Operation *op; 213 struct GNUNET_IDENTITY_Operation *op;
212 214
213 GNUNET_assert(NULL == h->reconnect_task); 215 GNUNET_assert (NULL == h->reconnect_task);
214 216
215 if (NULL != h->mq) 217 if (NULL != h->mq)
216 { 218 {
217 GNUNET_MQ_destroy(h->mq); 219 GNUNET_MQ_destroy (h->mq);
218 h->mq = NULL; 220 h->mq = NULL;
219 } 221 }
220 while (NULL != (op = h->op_head)) 222 while (NULL != (op = h->op_head))
221 { 223 {
222 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 224 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
223 if (NULL != op->cont) 225 if (NULL != op->cont)
224 op->cont(op->cls, "Error in communication with the identity service"); 226 op->cont (op->cls, "Error in communication with the identity service");
225 else if (NULL != op->cb) 227 else if (NULL != op->cb)
226 op->cb(op->cls, NULL, NULL, NULL); 228 op->cb (op->cls, NULL, NULL, NULL);
227 else if (NULL != op->create_cont) 229 else if (NULL != op->create_cont)
228 op->create_cont(op->cls, 230 op->create_cont (op->cls,
229 NULL, 231 NULL,
230 "Failed to communicate with the identity service"); 232 "Failed to communicate with the identity service");
231 GNUNET_free_non_null(op->pk); 233 GNUNET_free_non_null (op->pk);
232 GNUNET_free(op); 234 GNUNET_free (op);
233 } 235 }
234 GNUNET_CONTAINER_multihashmap_iterate(h->egos, &free_ego, h); 236 GNUNET_CONTAINER_multihashmap_iterate (h->egos, &free_ego, h);
235 LOG(GNUNET_ERROR_TYPE_DEBUG, 237 LOG (GNUNET_ERROR_TYPE_DEBUG,
236 "Scheduling task to reconnect to identity service in %s.\n", 238 "Scheduling task to reconnect to identity service in %s.\n",
237 GNUNET_STRINGS_relative_time_to_string(h->reconnect_delay, GNUNET_YES)); 239 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
238 h->reconnect_task = 240 h->reconnect_task =
239 GNUNET_SCHEDULER_add_delayed(h->reconnect_delay, &reconnect, h); 241 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
240 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF(h->reconnect_delay); 242 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
241} 243}
242 244
243 245
@@ -250,11 +252,11 @@ reschedule_connect(struct GNUNET_IDENTITY_Handle *h)
250 * @param error error code 252 * @param error error code
251 */ 253 */
252static void 254static void
253mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 255mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
254{ 256{
255 struct GNUNET_IDENTITY_Handle *h = cls; 257 struct GNUNET_IDENTITY_Handle *h = cls;
256 258
257 reschedule_connect(h); 259 reschedule_connect (h);
258} 260}
259 261
260 262
@@ -267,10 +269,10 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
267 * @return #GNUNET_OK if the message is well-formed 269 * @return #GNUNET_OK if the message is well-formed
268 */ 270 */
269static int 271static int
270check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 272check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
271{ 273{
272 if (sizeof(*rcm) != htons(rcm->header.size)) 274 if (sizeof(*rcm) != htons (rcm->header.size))
273 GNUNET_MQ_check_zero_termination(rcm); 275 GNUNET_MQ_check_zero_termination (rcm);
274 return GNUNET_OK; 276 return GNUNET_OK;
275} 277}
276 278
@@ -282,29 +284,29 @@ check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
282 * @param rcm result message received 284 * @param rcm result message received
283 */ 285 */
284static void 286static void
285handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 287handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
286{ 288{
287 struct GNUNET_IDENTITY_Handle *h = cls; 289 struct GNUNET_IDENTITY_Handle *h = cls;
288 struct GNUNET_IDENTITY_Operation *op; 290 struct GNUNET_IDENTITY_Operation *op;
289 uint16_t size = ntohs(rcm->header.size) - sizeof(*rcm); 291 uint16_t size = ntohs (rcm->header.size) - sizeof(*rcm);
290 const char *str = (0 == size) ? NULL : (const char *)&rcm[1]; 292 const char *str = (0 == size) ? NULL : (const char *) &rcm[1];
291 293
292 op = h->op_head; 294 op = h->op_head;
293 if (NULL == op) 295 if (NULL == op)
294 { 296 {
295 GNUNET_break(0); 297 GNUNET_break (0);
296 reschedule_connect(h); 298 reschedule_connect (h);
297 return; 299 return;
298 } 300 }
299 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 301 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
300 if (NULL != op->cont) 302 if (NULL != op->cont)
301 op->cont(op->cls, str); 303 op->cont (op->cls, str);
302 else if (NULL != op->cb) 304 else if (NULL != op->cb)
303 op->cb(op->cls, NULL, NULL, NULL); 305 op->cb (op->cls, NULL, NULL, NULL);
304 else if (NULL != op->create_cont) 306 else if (NULL != op->create_cont)
305 op->create_cont(op->cls, (NULL == str) ? op->pk : NULL, str); 307 op->create_cont (op->cls, (NULL == str) ? op->pk : NULL, str);
306 GNUNET_free_non_null(op->pk); 308 GNUNET_free_non_null (op->pk);
307 GNUNET_free(op); 309 GNUNET_free (op);
308} 310}
309 311
310 312
@@ -316,18 +318,18 @@ handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
316 * @return #GNUNET_OK if the message is well-formed 318 * @return #GNUNET_OK if the message is well-formed
317 */ 319 */
318static int 320static int
319check_identity_update(void *cls, const struct UpdateMessage *um) 321check_identity_update (void *cls, const struct UpdateMessage *um)
320{ 322{
321 uint16_t size = ntohs(um->header.size); 323 uint16_t size = ntohs (um->header.size);
322 uint16_t name_len = ntohs(um->name_len); 324 uint16_t name_len = ntohs (um->name_len);
323 const char *str = (const char *)&um[1]; 325 const char *str = (const char *) &um[1];
324 326
325 if ((size != name_len + sizeof(struct UpdateMessage)) || 327 if ((size != name_len + sizeof(struct UpdateMessage)) ||
326 ((0 != name_len) && ('\0' != str[name_len - 1]))) 328 ((0 != name_len) && ('\0' != str[name_len - 1])))
327 { 329 {
328 GNUNET_break(0); 330 GNUNET_break (0);
329 return GNUNET_SYSERR; 331 return GNUNET_SYSERR;
330 } 332 }
331 return GNUNET_OK; 333 return GNUNET_OK;
332} 334}
333 335
@@ -339,70 +341,70 @@ check_identity_update(void *cls, const struct UpdateMessage *um)
339 * @param um message received 341 * @param um message received
340 */ 342 */
341static void 343static void
342handle_identity_update(void *cls, const struct UpdateMessage *um) 344handle_identity_update (void *cls, const struct UpdateMessage *um)
343{ 345{
344 struct GNUNET_IDENTITY_Handle *h = cls; 346 struct GNUNET_IDENTITY_Handle *h = cls;
345 uint16_t name_len = ntohs(um->name_len); 347 uint16_t name_len = ntohs (um->name_len);
346 const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; 348 const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
347 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 349 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
348 struct GNUNET_HashCode id; 350 struct GNUNET_HashCode id;
349 struct GNUNET_IDENTITY_Ego *ego; 351 struct GNUNET_IDENTITY_Ego *ego;
350 352
351 if (GNUNET_YES == ntohs(um->end_of_list)) 353 if (GNUNET_YES == ntohs (um->end_of_list))
352 { 354 {
353 /* end of initial list of data */ 355 /* end of initial list of data */
354 if (NULL != h->cb) 356 if (NULL != h->cb)
355 h->cb(h->cb_cls, NULL, NULL, NULL); 357 h->cb (h->cb_cls, NULL, NULL, NULL);
356 return; 358 return;
357 } 359 }
358 GNUNET_CRYPTO_ecdsa_key_get_public(&um->private_key, &pub); 360 GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub);
359 GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); 361 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id);
360 ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); 362 ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
361 if (NULL == ego) 363 if (NULL == ego)
364 {
365 /* ego was created */
366 if (NULL == str)
362 { 367 {
363 /* ego was created */ 368 /* deletion of unknown ego? not allowed */
364 if (NULL == str) 369 GNUNET_break (0);
365 { 370 reschedule_connect (h);
366 /* deletion of unknown ego? not allowed */ 371 return;
367 GNUNET_break(0);
368 reschedule_connect(h);
369 return;
370 }
371 ego = GNUNET_new(struct GNUNET_IDENTITY_Ego);
372 ego->pk = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey);
373 *ego->pk = um->private_key;
374 ego->name = GNUNET_strdup(str);
375 ego->id = id;
376 GNUNET_assert(GNUNET_YES ==
377 GNUNET_CONTAINER_multihashmap_put(
378 h->egos,
379 &ego->id,
380 ego,
381 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
382 } 372 }
373 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
374 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
375 *ego->pk = um->private_key;
376 ego->name = GNUNET_strdup (str);
377 ego->id = id;
378 GNUNET_assert (GNUNET_YES ==
379 GNUNET_CONTAINER_multihashmap_put (
380 h->egos,
381 &ego->id,
382 ego,
383 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
384 }
383 if (NULL == str) 385 if (NULL == str)
384 { 386 {
385 /* ego was deleted */ 387 /* ego was deleted */
386 GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(h->egos, 388 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (h->egos,
387 &ego->id, 389 &ego->id,
388 ego)); 390 ego));
389 } 391 }
390 else 392 else
391 { 393 {
392 /* ego changed name */ 394 /* ego changed name */
393 GNUNET_free(ego->name); 395 GNUNET_free (ego->name);
394 ego->name = GNUNET_strdup(str); 396 ego->name = GNUNET_strdup (str);
395 } 397 }
396 /* inform application about change */ 398 /* inform application about change */
397 if (NULL != h->cb) 399 if (NULL != h->cb)
398 h->cb(h->cb_cls, ego, &ego->ctx, str); 400 h->cb (h->cb_cls, ego, &ego->ctx, str);
399 /* complete deletion */ 401 /* complete deletion */
400 if (NULL == str) 402 if (NULL == str)
401 { 403 {
402 GNUNET_free(ego->pk); 404 GNUNET_free (ego->pk);
403 GNUNET_free(ego->name); 405 GNUNET_free (ego->name);
404 GNUNET_free(ego); 406 GNUNET_free (ego);
405 } 407 }
406} 408}
407 409
408 410
@@ -415,18 +417,18 @@ handle_identity_update(void *cls, const struct UpdateMessage *um)
415 * @return #GNUNET_OK if the message is well-formed 417 * @return #GNUNET_OK if the message is well-formed
416 */ 418 */
417static int 419static int
418check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) 420check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm)
419{ 421{
420 uint16_t size = ntohs(sdm->header.size) - sizeof(*sdm); 422 uint16_t size = ntohs (sdm->header.size) - sizeof(*sdm);
421 uint16_t name_len = ntohs(sdm->name_len); 423 uint16_t name_len = ntohs (sdm->name_len);
422 const char *str = (const char *)&sdm[1]; 424 const char *str = (const char *) &sdm[1];
423 425
424 if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1]))) 426 if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
425 { 427 {
426 GNUNET_break(0); 428 GNUNET_break (0);
427 return GNUNET_SYSERR; 429 return GNUNET_SYSERR;
428 } 430 }
429 GNUNET_break(0 == ntohs(sdm->reserved)); 431 GNUNET_break (0 == ntohs (sdm->reserved));
430 return GNUNET_OK; 432 return GNUNET_OK;
431} 433}
432 434
@@ -439,7 +441,7 @@ check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
439 * @param sdm message received 441 * @param sdm message received
440 */ 442 */
441static void 443static void
442handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) 444handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm)
443{ 445{
444 struct GNUNET_IDENTITY_Handle *h = cls; 446 struct GNUNET_IDENTITY_Handle *h = cls;
445 struct GNUNET_IDENTITY_Operation *op; 447 struct GNUNET_IDENTITY_Operation *op;
@@ -447,28 +449,28 @@ handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
447 struct GNUNET_HashCode id; 449 struct GNUNET_HashCode id;
448 struct GNUNET_IDENTITY_Ego *ego; 450 struct GNUNET_IDENTITY_Ego *ego;
449 451
450 GNUNET_CRYPTO_ecdsa_key_get_public(&sdm->private_key, &pub); 452 GNUNET_CRYPTO_ecdsa_key_get_public (&sdm->private_key, &pub);
451 GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); 453 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id);
452 ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); 454 ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id);
453 if (NULL == ego) 455 if (NULL == ego)
454 { 456 {
455 GNUNET_break(0); 457 GNUNET_break (0);
456 reschedule_connect(h); 458 reschedule_connect (h);
457 return; 459 return;
458 } 460 }
459 op = h->op_head; 461 op = h->op_head;
460 if (NULL == op) 462 if (NULL == op)
461 { 463 {
462 GNUNET_break(0); 464 GNUNET_break (0);
463 reschedule_connect(h); 465 reschedule_connect (h);
464 return; 466 return;
465 } 467 }
466 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
467 "Received SET_DEFAULT message from identity service\n"); 469 "Received SET_DEFAULT message from identity service\n");
468 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 470 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
469 if (NULL != op->cb) 471 if (NULL != op->cb)
470 op->cb(op->cls, ego, &ego->ctx, ego->name); 472 op->cb (op->cls, ego, &ego->ctx, ego->name);
471 GNUNET_free(op); 473 GNUNET_free (op);
472} 474}
473 475
474 476
@@ -478,38 +480,38 @@ handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm)
478 * @param cls handle to the identity service. 480 * @param cls handle to the identity service.
479 */ 481 */
480static void 482static void
481reconnect(void *cls) 483reconnect (void *cls)
482{ 484{
483 struct GNUNET_IDENTITY_Handle *h = cls; 485 struct GNUNET_IDENTITY_Handle *h = cls;
484 struct GNUNET_MQ_MessageHandler handlers[] = 486 struct GNUNET_MQ_MessageHandler handlers[] =
485 { GNUNET_MQ_hd_var_size(identity_result_code, 487 { GNUNET_MQ_hd_var_size (identity_result_code,
486 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, 488 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
487 struct ResultCodeMessage, 489 struct ResultCodeMessage,
488 h), 490 h),
489 GNUNET_MQ_hd_var_size(identity_update, 491 GNUNET_MQ_hd_var_size (identity_update,
490 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, 492 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
491 struct UpdateMessage, 493 struct UpdateMessage,
492 h), 494 h),
493 GNUNET_MQ_hd_var_size(identity_set_default, 495 GNUNET_MQ_hd_var_size (identity_set_default,
494 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, 496 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
495 struct SetDefaultMessage, 497 struct SetDefaultMessage,
496 h), 498 h),
497 GNUNET_MQ_handler_end() }; 499 GNUNET_MQ_handler_end () };
498 struct GNUNET_MQ_Envelope *env; 500 struct GNUNET_MQ_Envelope *env;
499 struct GNUNET_MessageHeader *msg; 501 struct GNUNET_MessageHeader *msg;
500 502
501 h->reconnect_task = NULL; 503 h->reconnect_task = NULL;
502 LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); 504 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n");
503 GNUNET_assert(NULL == h->mq); 505 GNUNET_assert (NULL == h->mq);
504 h->mq = 506 h->mq =
505 GNUNET_CLIENT_connect(h->cfg, "identity", handlers, &mq_error_handler, h); 507 GNUNET_CLIENT_connect (h->cfg, "identity", handlers, &mq_error_handler, h);
506 if (NULL == h->mq) 508 if (NULL == h->mq)
507 return; 509 return;
508 if (NULL != h->cb) 510 if (NULL != h->cb)
509 { 511 {
510 env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_IDENTITY_START); 512 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_IDENTITY_START);
511 GNUNET_MQ_send(h->mq, env); 513 GNUNET_MQ_send (h->mq, env);
512 } 514 }
513} 515}
514 516
515 517
@@ -522,23 +524,23 @@ reconnect(void *cls)
522 * @return handle to use 524 * @return handle to use
523 */ 525 */
524struct GNUNET_IDENTITY_Handle * 526struct GNUNET_IDENTITY_Handle *
525GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, 527GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
526 GNUNET_IDENTITY_Callback cb, 528 GNUNET_IDENTITY_Callback cb,
527 void *cb_cls) 529 void *cb_cls)
528{ 530{
529 struct GNUNET_IDENTITY_Handle *h; 531 struct GNUNET_IDENTITY_Handle *h;
530 532
531 h = GNUNET_new(struct GNUNET_IDENTITY_Handle); 533 h = GNUNET_new (struct GNUNET_IDENTITY_Handle);
532 h->cfg = cfg; 534 h->cfg = cfg;
533 h->cb = cb; 535 h->cb = cb;
534 h->cb_cls = cb_cls; 536 h->cb_cls = cb_cls;
535 h->egos = GNUNET_CONTAINER_multihashmap_create(16, GNUNET_YES); 537 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
536 reconnect(h); 538 reconnect (h);
537 if (NULL == h->mq) 539 if (NULL == h->mq)
538 { 540 {
539 GNUNET_free(h); 541 GNUNET_free (h);
540 return NULL; 542 return NULL;
541 } 543 }
542 return h; 544 return h;
543} 545}
544 546
@@ -550,7 +552,7 @@ GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg,
550 * @return associated ECC key, valid as long as the ego is valid 552 * @return associated ECC key, valid as long as the ego is valid
551 */ 553 */
552const struct GNUNET_CRYPTO_EcdsaPrivateKey * 554const struct GNUNET_CRYPTO_EcdsaPrivateKey *
553GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego) 555GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego)
554{ 556{
555 return ego->pk; 557 return ego->pk;
556} 558}
@@ -563,10 +565,10 @@ GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
563 * @param pk set to ego's public key 565 * @param pk set to ego's public key
564 */ 566 */
565void 567void
566GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, 568GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego,
567 struct GNUNET_CRYPTO_EcdsaPublicKey *pk) 569 struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
568{ 570{
569 GNUNET_CRYPTO_ecdsa_key_get_public(ego->pk, pk); 571 GNUNET_CRYPTO_ecdsa_key_get_public (ego->pk, pk);
570} 572}
571 573
572 574
@@ -581,10 +583,10 @@ GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego,
581 * @return handle to abort the operation 583 * @return handle to abort the operation
582 */ 584 */
583struct GNUNET_IDENTITY_Operation * 585struct GNUNET_IDENTITY_Operation *
584GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, 586GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h,
585 const char *service_name, 587 const char *service_name,
586 GNUNET_IDENTITY_Callback cb, 588 GNUNET_IDENTITY_Callback cb,
587 void *cb_cls) 589 void *cb_cls)
588{ 590{
589 struct GNUNET_IDENTITY_Operation *op; 591 struct GNUNET_IDENTITY_Operation *op;
590 struct GNUNET_MQ_Envelope *env; 592 struct GNUNET_MQ_Envelope *env;
@@ -593,24 +595,24 @@ GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h,
593 595
594 if (NULL == h->mq) 596 if (NULL == h->mq)
595 return NULL; 597 return NULL;
596 GNUNET_assert(NULL != h->cb); 598 GNUNET_assert (NULL != h->cb);
597 slen = strlen(service_name) + 1; 599 slen = strlen (service_name) + 1;
598 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage)) 600 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
599 { 601 {
600 GNUNET_break(0); 602 GNUNET_break (0);
601 return NULL; 603 return NULL;
602 } 604 }
603 op = GNUNET_new(struct GNUNET_IDENTITY_Operation); 605 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
604 op->h = h; 606 op->h = h;
605 op->cb = cb; 607 op->cb = cb;
606 op->cls = cb_cls; 608 op->cls = cb_cls;
607 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 609 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
608 env = 610 env =
609 GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); 611 GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
610 gdm->name_len = htons(slen); 612 gdm->name_len = htons (slen);
611 gdm->reserved = htons(0); 613 gdm->reserved = htons (0);
612 GNUNET_memcpy(&gdm[1], service_name, slen); 614 GNUNET_memcpy (&gdm[1], service_name, slen);
613 GNUNET_MQ_send(h->mq, env); 615 GNUNET_MQ_send (h->mq, env);
614 return op; 616 return op;
615} 617}
616 618
@@ -626,11 +628,11 @@ GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h,
626 * @return handle to abort the operation 628 * @return handle to abort the operation
627 */ 629 */
628struct GNUNET_IDENTITY_Operation * 630struct GNUNET_IDENTITY_Operation *
629GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, 631GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h,
630 const char *service_name, 632 const char *service_name,
631 struct GNUNET_IDENTITY_Ego *ego, 633 struct GNUNET_IDENTITY_Ego *ego,
632 GNUNET_IDENTITY_Continuation cont, 634 GNUNET_IDENTITY_Continuation cont,
633 void *cont_cls) 635 void *cont_cls)
634{ 636{
635 struct GNUNET_IDENTITY_Operation *op; 637 struct GNUNET_IDENTITY_Operation *op;
636 struct GNUNET_MQ_Envelope *env; 638 struct GNUNET_MQ_Envelope *env;
@@ -639,25 +641,25 @@ GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h,
639 641
640 if (NULL == h->mq) 642 if (NULL == h->mq)
641 return NULL; 643 return NULL;
642 GNUNET_assert(NULL != h->cb); 644 GNUNET_assert (NULL != h->cb);
643 slen = strlen(service_name) + 1; 645 slen = strlen (service_name) + 1;
644 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage)) 646 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
645 { 647 {
646 GNUNET_break(0); 648 GNUNET_break (0);
647 return NULL; 649 return NULL;
648 } 650 }
649 op = GNUNET_new(struct GNUNET_IDENTITY_Operation); 651 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
650 op->h = h; 652 op->h = h;
651 op->cont = cont; 653 op->cont = cont;
652 op->cls = cont_cls; 654 op->cls = cont_cls;
653 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 655 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
654 env = 656 env =
655 GNUNET_MQ_msg_extra(sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); 657 GNUNET_MQ_msg_extra (sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
656 sdm->name_len = htons(slen); 658 sdm->name_len = htons (slen);
657 sdm->reserved = htons(0); 659 sdm->reserved = htons (0);
658 sdm->private_key = *ego->pk; 660 sdm->private_key = *ego->pk;
659 GNUNET_memcpy(&sdm[1], service_name, slen); 661 GNUNET_memcpy (&sdm[1], service_name, slen);
660 GNUNET_MQ_send(h->mq, env); 662 GNUNET_MQ_send (h->mq, env);
661 return op; 663 return op;
662} 664}
663 665
@@ -672,10 +674,10 @@ GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h,
672 * @return handle to abort the operation 674 * @return handle to abort the operation
673 */ 675 */
674struct GNUNET_IDENTITY_Operation * 676struct GNUNET_IDENTITY_Operation *
675GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, 677GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
676 const char *name, 678 const char *name,
677 GNUNET_IDENTITY_CreateContinuation cont, 679 GNUNET_IDENTITY_CreateContinuation cont,
678 void *cont_cls) 680 void *cont_cls)
679{ 681{
680 struct GNUNET_IDENTITY_Operation *op; 682 struct GNUNET_IDENTITY_Operation *op;
681 struct GNUNET_MQ_Envelope *env; 683 struct GNUNET_MQ_Envelope *env;
@@ -685,25 +687,25 @@ GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h,
685 687
686 if (NULL == h->mq) 688 if (NULL == h->mq)
687 return NULL; 689 return NULL;
688 slen = strlen(name) + 1; 690 slen = strlen (name) + 1;
689 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage)) 691 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage))
690 { 692 {
691 GNUNET_break(0); 693 GNUNET_break (0);
692 return NULL; 694 return NULL;
693 } 695 }
694 op = GNUNET_new(struct GNUNET_IDENTITY_Operation); 696 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
695 op->h = h; 697 op->h = h;
696 op->create_cont = cont; 698 op->create_cont = cont;
697 op->cls = cont_cls; 699 op->cls = cont_cls;
698 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 700 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
699 env = GNUNET_MQ_msg_extra(crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); 701 env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
700 crm->name_len = htons(slen); 702 crm->name_len = htons (slen);
701 crm->reserved = htons(0); 703 crm->reserved = htons (0);
702 pk = GNUNET_CRYPTO_ecdsa_key_create(); 704 pk = GNUNET_CRYPTO_ecdsa_key_create ();
703 crm->private_key = *pk; 705 crm->private_key = *pk;
704 op->pk = pk; 706 op->pk = pk;
705 GNUNET_memcpy(&crm[1], name, slen); 707 GNUNET_memcpy (&crm[1], name, slen);
706 GNUNET_MQ_send(h->mq, env); 708 GNUNET_MQ_send (h->mq, env);
707 return op; 709 return op;
708} 710}
709 711
@@ -719,11 +721,11 @@ GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h,
719 * @return handle to abort the operation 721 * @return handle to abort the operation
720 */ 722 */
721struct GNUNET_IDENTITY_Operation * 723struct GNUNET_IDENTITY_Operation *
722GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, 724GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h,
723 const char *old_name, 725 const char *old_name,
724 const char *new_name, 726 const char *new_name,
725 GNUNET_IDENTITY_Continuation cb, 727 GNUNET_IDENTITY_Continuation cb,
726 void *cb_cls) 728 void *cb_cls)
727{ 729{
728 struct GNUNET_IDENTITY_Operation *op; 730 struct GNUNET_IDENTITY_Operation *op;
729 struct GNUNET_MQ_Envelope *env; 731 struct GNUNET_MQ_Envelope *env;
@@ -734,30 +736,30 @@ GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h,
734 736
735 if (NULL == h->mq) 737 if (NULL == h->mq)
736 return NULL; 738 return NULL;
737 slen_old = strlen(old_name) + 1; 739 slen_old = strlen (old_name) + 1;
738 slen_new = strlen(new_name) + 1; 740 slen_new = strlen (new_name) + 1;
739 if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) || 741 if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) ||
740 (slen_new >= GNUNET_MAX_MESSAGE_SIZE) || 742 (slen_new >= GNUNET_MAX_MESSAGE_SIZE) ||
741 (slen_old + slen_new >= 743 (slen_old + slen_new >=
742 GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage))) 744 GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage)))
743 { 745 {
744 GNUNET_break(0); 746 GNUNET_break (0);
745 return NULL; 747 return NULL;
746 } 748 }
747 op = GNUNET_new(struct GNUNET_IDENTITY_Operation); 749 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
748 op->h = h; 750 op->h = h;
749 op->cont = cb; 751 op->cont = cb;
750 op->cls = cb_cls; 752 op->cls = cb_cls;
751 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 753 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
752 env = GNUNET_MQ_msg_extra(grm, 754 env = GNUNET_MQ_msg_extra (grm,
753 slen_old + slen_new, 755 slen_old + slen_new,
754 GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); 756 GNUNET_MESSAGE_TYPE_IDENTITY_RENAME);
755 grm->old_name_len = htons(slen_old); 757 grm->old_name_len = htons (slen_old);
756 grm->new_name_len = htons(slen_new); 758 grm->new_name_len = htons (slen_new);
757 dst = (char *)&grm[1]; 759 dst = (char *) &grm[1];
758 GNUNET_memcpy(dst, old_name, slen_old); 760 GNUNET_memcpy (dst, old_name, slen_old);
759 GNUNET_memcpy(&dst[slen_old], new_name, slen_new); 761 GNUNET_memcpy (&dst[slen_old], new_name, slen_new);
760 GNUNET_MQ_send(h->mq, env); 762 GNUNET_MQ_send (h->mq, env);
761 return op; 763 return op;
762} 764}
763 765
@@ -772,10 +774,10 @@ GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h,
772 * @return handle to abort the operation 774 * @return handle to abort the operation
773 */ 775 */
774struct GNUNET_IDENTITY_Operation * 776struct GNUNET_IDENTITY_Operation *
775GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, 777GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h,
776 const char *name, 778 const char *name,
777 GNUNET_IDENTITY_Continuation cb, 779 GNUNET_IDENTITY_Continuation cb,
778 void *cb_cls) 780 void *cb_cls)
779{ 781{
780 struct GNUNET_IDENTITY_Operation *op; 782 struct GNUNET_IDENTITY_Operation *op;
781 struct GNUNET_MQ_Envelope *env; 783 struct GNUNET_MQ_Envelope *env;
@@ -784,22 +786,22 @@ GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h,
784 786
785 if (NULL == h->mq) 787 if (NULL == h->mq)
786 return NULL; 788 return NULL;
787 slen = strlen(name) + 1; 789 slen = strlen (name) + 1;
788 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage)) 790 if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage))
789 { 791 {
790 GNUNET_break(0); 792 GNUNET_break (0);
791 return NULL; 793 return NULL;
792 } 794 }
793 op = GNUNET_new(struct GNUNET_IDENTITY_Operation); 795 op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
794 op->h = h; 796 op->h = h;
795 op->cont = cb; 797 op->cont = cb;
796 op->cls = cb_cls; 798 op->cls = cb_cls;
797 GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); 799 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
798 env = GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); 800 env = GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE);
799 gdm->name_len = htons(slen); 801 gdm->name_len = htons (slen);
800 gdm->reserved = htons(0); 802 gdm->reserved = htons (0);
801 GNUNET_memcpy(&gdm[1], name, slen); 803 GNUNET_memcpy (&gdm[1], name, slen);
802 GNUNET_MQ_send(h->mq, env); 804 GNUNET_MQ_send (h->mq, env);
803 return op; 805 return op;
804} 806}
805 807
@@ -813,16 +815,16 @@ GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h,
813 * @param op operation to cancel 815 * @param op operation to cancel
814 */ 816 */
815void 817void
816GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op) 818GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
817{ 819{
818 op->cont = NULL; 820 op->cont = NULL;
819 op->cb = NULL; 821 op->cb = NULL;
820 op->create_cont = NULL; 822 op->create_cont = NULL;
821 if (NULL != op->pk) 823 if (NULL != op->pk)
822 { 824 {
823 GNUNET_free(op->pk); 825 GNUNET_free (op->pk);
824 op->pk = NULL; 826 op->pk = NULL;
825 } 827 }
826} 828}
827 829
828 830
@@ -832,35 +834,35 @@ GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
832 * @param h handle to destroy 834 * @param h handle to destroy
833 */ 835 */
834void 836void
835GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h) 837GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
836{ 838{
837 struct GNUNET_IDENTITY_Operation *op; 839 struct GNUNET_IDENTITY_Operation *op;
838 840
839 GNUNET_assert(NULL != h); 841 GNUNET_assert (NULL != h);
840 if (h->reconnect_task != NULL) 842 if (h->reconnect_task != NULL)
841 { 843 {
842 GNUNET_SCHEDULER_cancel(h->reconnect_task); 844 GNUNET_SCHEDULER_cancel (h->reconnect_task);
843 h->reconnect_task = NULL; 845 h->reconnect_task = NULL;
844 } 846 }
845 if (NULL != h->egos) 847 if (NULL != h->egos)
846 { 848 {
847 GNUNET_CONTAINER_multihashmap_iterate(h->egos, &free_ego, h); 849 GNUNET_CONTAINER_multihashmap_iterate (h->egos, &free_ego, h);
848 GNUNET_CONTAINER_multihashmap_destroy(h->egos); 850 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
849 h->egos = NULL; 851 h->egos = NULL;
850 } 852 }
851 while (NULL != (op = h->op_head)) 853 while (NULL != (op = h->op_head))
852 { 854 {
853 GNUNET_break(NULL == op->cont); 855 GNUNET_break (NULL == op->cont);
854 GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); 856 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
855 GNUNET_free_non_null(op->pk); 857 GNUNET_free_non_null (op->pk);
856 GNUNET_free(op); 858 GNUNET_free (op);
857 } 859 }
858 if (NULL != h->mq) 860 if (NULL != h->mq)
859 { 861 {
860 GNUNET_MQ_destroy(h->mq); 862 GNUNET_MQ_destroy (h->mq);
861 h->mq = NULL; 863 h->mq = NULL;
862 } 864 }
863 GNUNET_free(h); 865 GNUNET_free (h);
864} 866}
865 867
866/* end of identity_api.c */ 868/* end of identity_api.c */
diff --git a/src/identity/identity_api_lookup.c b/src/identity/identity_api_lookup.c
index faf647c07..108fc7fcf 100644
--- a/src/identity/identity_api_lookup.c
+++ b/src/identity/identity_api_lookup.c
@@ -28,13 +28,14 @@
28#include "gnunet_identity_service.h" 28#include "gnunet_identity_service.h"
29#include "identity.h" 29#include "identity.h"
30 30
31#define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
32 32
33 33
34/** 34/**
35 * Handle for ego lookup. 35 * Handle for ego lookup.
36 */ 36 */
37struct GNUNET_IDENTITY_EgoLookup { 37struct GNUNET_IDENTITY_EgoLookup
38{
38 /** 39 /**
39 * Connection to service. 40 * Connection to service.
40 */ 41 */
@@ -66,10 +67,10 @@ struct GNUNET_IDENTITY_EgoLookup {
66 * @return #GNUNET_OK if the message is well-formed 67 * @return #GNUNET_OK if the message is well-formed
67 */ 68 */
68static int 69static int
69check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 70check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
70{ 71{
71 if (sizeof(*rcm) != htons(rcm->header.size)) 72 if (sizeof(*rcm) != htons (rcm->header.size))
72 GNUNET_MQ_check_zero_termination(rcm); 73 GNUNET_MQ_check_zero_termination (rcm);
73 return GNUNET_OK; 74 return GNUNET_OK;
74} 75}
75 76
@@ -81,12 +82,12 @@ check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
81 * @param rcm result message received 82 * @param rcm result message received
82 */ 83 */
83static void 84static void
84handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 85handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
85{ 86{
86 struct GNUNET_IDENTITY_EgoLookup *el = cls; 87 struct GNUNET_IDENTITY_EgoLookup *el = cls;
87 88
88 el->cb(el->cb_cls, NULL); 89 el->cb (el->cb_cls, NULL);
89 GNUNET_IDENTITY_ego_lookup_cancel(el); 90 GNUNET_IDENTITY_ego_lookup_cancel (el);
90} 91}
91 92
92 93
@@ -98,18 +99,18 @@ handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
98 * @return #GNUNET_OK if the message is well-formed 99 * @return #GNUNET_OK if the message is well-formed
99 */ 100 */
100static int 101static int
101check_identity_update(void *cls, const struct UpdateMessage *um) 102check_identity_update (void *cls, const struct UpdateMessage *um)
102{ 103{
103 uint16_t size = ntohs(um->header.size); 104 uint16_t size = ntohs (um->header.size);
104 uint16_t name_len = ntohs(um->name_len); 105 uint16_t name_len = ntohs (um->name_len);
105 const char *str = (const char *)&um[1]; 106 const char *str = (const char *) &um[1];
106 107
107 if ((size != name_len + sizeof(struct UpdateMessage)) || 108 if ((size != name_len + sizeof(struct UpdateMessage)) ||
108 ((0 != name_len) && ('\0' != str[name_len - 1]))) 109 ((0 != name_len) && ('\0' != str[name_len - 1])))
109 { 110 {
110 GNUNET_break(0); 111 GNUNET_break (0);
111 return GNUNET_SYSERR; 112 return GNUNET_SYSERR;
112 } 113 }
113 return GNUNET_OK; 114 return GNUNET_OK;
114} 115}
115 116
@@ -121,23 +122,23 @@ check_identity_update(void *cls, const struct UpdateMessage *um)
121 * @param um message received 122 * @param um message received
122 */ 123 */
123static void 124static void
124handle_identity_update(void *cls, const struct UpdateMessage *um) 125handle_identity_update (void *cls, const struct UpdateMessage *um)
125{ 126{
126 struct GNUNET_IDENTITY_EgoLookup *el = cls; 127 struct GNUNET_IDENTITY_EgoLookup *el = cls;
127 uint16_t name_len = ntohs(um->name_len); 128 uint16_t name_len = ntohs (um->name_len);
128 const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; 129 const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
129 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 130 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
130 struct GNUNET_HashCode id; 131 struct GNUNET_HashCode id;
131 struct GNUNET_IDENTITY_Ego ego; 132 struct GNUNET_IDENTITY_Ego ego;
132 133
133 GNUNET_break(GNUNET_YES != ntohs(um->end_of_list)); 134 GNUNET_break (GNUNET_YES != ntohs (um->end_of_list));
134 GNUNET_CRYPTO_ecdsa_key_get_public(&um->private_key, &pub); 135 GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub);
135 GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); 136 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id);
136 ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)&um->private_key; 137 ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) &um->private_key;
137 ego.name = (char *)str; 138 ego.name = (char *) str;
138 ego.id = id; 139 ego.id = id;
139 el->cb(el->cb_cls, &ego); 140 el->cb (el->cb_cls, &ego);
140 GNUNET_IDENTITY_ego_lookup_cancel(el); 141 GNUNET_IDENTITY_ego_lookup_cancel (el);
141} 142}
142 143
143 144
@@ -150,11 +151,11 @@ handle_identity_update(void *cls, const struct UpdateMessage *um)
150 * @param error error code 151 * @param error error code
151 */ 152 */
152static void 153static void
153mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 154mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
154{ 155{
155 struct GNUNET_IDENTITY_EgoLookup *el = cls; 156 struct GNUNET_IDENTITY_EgoLookup *el = cls;
156 157
157 el->cb(el->cb_cls, NULL); 158 el->cb (el->cb_cls, NULL);
158} 159}
159 160
160 161
@@ -168,46 +169,46 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
168 * @return NULL on error 169 * @return NULL on error
169 */ 170 */
170struct GNUNET_IDENTITY_EgoLookup * 171struct GNUNET_IDENTITY_EgoLookup *
171GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, 172GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
172 const char *name, 173 const char *name,
173 GNUNET_IDENTITY_EgoCallback cb, 174 GNUNET_IDENTITY_EgoCallback cb,
174 void *cb_cls) 175 void *cb_cls)
175{ 176{
176 struct GNUNET_IDENTITY_EgoLookup *el; 177 struct GNUNET_IDENTITY_EgoLookup *el;
177 struct GNUNET_MQ_Envelope *env; 178 struct GNUNET_MQ_Envelope *env;
178 struct GNUNET_MessageHeader *req; 179 struct GNUNET_MessageHeader *req;
179 size_t nlen; 180 size_t nlen;
180 181
181 GNUNET_assert(NULL != cb); 182 GNUNET_assert (NULL != cb);
182 el = GNUNET_new(struct GNUNET_IDENTITY_EgoLookup); 183 el = GNUNET_new (struct GNUNET_IDENTITY_EgoLookup);
183 el->cb = cb; 184 el->cb = cb;
184 el->cb_cls = cb_cls; 185 el->cb_cls = cb_cls;
185 { 186 {
186 struct GNUNET_MQ_MessageHandler handlers[] = 187 struct GNUNET_MQ_MessageHandler handlers[] =
187 { GNUNET_MQ_hd_var_size(identity_result_code, 188 { GNUNET_MQ_hd_var_size (identity_result_code,
188 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, 189 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
189 struct ResultCodeMessage, 190 struct ResultCodeMessage,
190 el), 191 el),
191 GNUNET_MQ_hd_var_size(identity_update, 192 GNUNET_MQ_hd_var_size (identity_update,
192 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, 193 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
193 struct UpdateMessage, 194 struct UpdateMessage,
194 el), 195 el),
195 GNUNET_MQ_handler_end() }; 196 GNUNET_MQ_handler_end () };
196 197
197 el->mq = 198 el->mq =
198 GNUNET_CLIENT_connect(cfg, "identity", handlers, &mq_error_handler, el); 199 GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
199 } 200 }
200 if (NULL == el->mq) 201 if (NULL == el->mq)
201 { 202 {
202 GNUNET_break(0); 203 GNUNET_break (0);
203 GNUNET_free(el); 204 GNUNET_free (el);
204 return NULL; 205 return NULL;
205 } 206 }
206 el->name = GNUNET_strdup(name); 207 el->name = GNUNET_strdup (name);
207 nlen = strlen(name) + 1; 208 nlen = strlen (name) + 1;
208 env = GNUNET_MQ_msg_extra(req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP); 209 env = GNUNET_MQ_msg_extra (req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP);
209 memcpy(&req[1], name, nlen); 210 memcpy (&req[1], name, nlen);
210 GNUNET_MQ_send(el->mq, env); 211 GNUNET_MQ_send (el->mq, env);
211 return el; 212 return el;
212} 213}
213 214
@@ -218,11 +219,11 @@ GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg,
218 * @param el handle for lookup to abort 219 * @param el handle for lookup to abort
219 */ 220 */
220void 221void
221GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el) 222GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el)
222{ 223{
223 GNUNET_MQ_destroy(el->mq); 224 GNUNET_MQ_destroy (el->mq);
224 GNUNET_free(el->name); 225 GNUNET_free (el->name);
225 GNUNET_free(el); 226 GNUNET_free (el);
226} 227}
227 228
228 229
diff --git a/src/identity/identity_api_suffix_lookup.c b/src/identity/identity_api_suffix_lookup.c
index 51d8f39a6..2667ddbc8 100644
--- a/src/identity/identity_api_suffix_lookup.c
+++ b/src/identity/identity_api_suffix_lookup.c
@@ -28,13 +28,14 @@
28#include "gnunet_identity_service.h" 28#include "gnunet_identity_service.h"
29#include "identity.h" 29#include "identity.h"
30 30
31#define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
32 32
33 33
34/** 34/**
35 * Handle for ego lookup. 35 * Handle for ego lookup.
36 */ 36 */
37struct GNUNET_IDENTITY_EgoSuffixLookup { 37struct GNUNET_IDENTITY_EgoSuffixLookup
38{
38 /** 39 /**
39 * Connection to service. 40 * Connection to service.
40 */ 41 */
@@ -66,11 +67,11 @@ struct GNUNET_IDENTITY_EgoSuffixLookup {
66 * @return #GNUNET_OK if the message is well-formed 67 * @return #GNUNET_OK if the message is well-formed
67 */ 68 */
68static int 69static int
69check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 70check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
70{ 71{
71 (void)cls; 72 (void) cls;
72 if (sizeof(*rcm) != htons(rcm->header.size)) 73 if (sizeof(*rcm) != htons (rcm->header.size))
73 GNUNET_MQ_check_zero_termination(rcm); 74 GNUNET_MQ_check_zero_termination (rcm);
74 return GNUNET_OK; 75 return GNUNET_OK;
75} 76}
76 77
@@ -82,13 +83,13 @@ check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
82 * @param rcm result message received 83 * @param rcm result message received
83 */ 84 */
84static void 85static void
85handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) 86handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
86{ 87{
87 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls; 88 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
88 89
89 (void)rcm; 90 (void) rcm;
90 el->cb(el->cb_cls, NULL, NULL); 91 el->cb (el->cb_cls, NULL, NULL);
91 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(el); 92 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (el);
92} 93}
93 94
94 95
@@ -100,19 +101,19 @@ handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm)
100 * @return #GNUNET_OK if the message is well-formed 101 * @return #GNUNET_OK if the message is well-formed
101 */ 102 */
102static int 103static int
103check_identity_update(void *cls, const struct UpdateMessage *um) 104check_identity_update (void *cls, const struct UpdateMessage *um)
104{ 105{
105 uint16_t size = ntohs(um->header.size); 106 uint16_t size = ntohs (um->header.size);
106 uint16_t name_len = ntohs(um->name_len); 107 uint16_t name_len = ntohs (um->name_len);
107 const char *str = (const char *)&um[1]; 108 const char *str = (const char *) &um[1];
108 109
109 (void)cls; 110 (void) cls;
110 if ((size != name_len + sizeof(struct UpdateMessage)) || 111 if ((size != name_len + sizeof(struct UpdateMessage)) ||
111 ((0 != name_len) && ('\0' != str[name_len - 1]))) 112 ((0 != name_len) && ('\0' != str[name_len - 1])))
112 { 113 {
113 GNUNET_break(0); 114 GNUNET_break (0);
114 return GNUNET_SYSERR; 115 return GNUNET_SYSERR;
115 } 116 }
116 return GNUNET_OK; 117 return GNUNET_OK;
117} 118}
118 119
@@ -124,14 +125,14 @@ check_identity_update(void *cls, const struct UpdateMessage *um)
124 * @param um message received 125 * @param um message received
125 */ 126 */
126static void 127static void
127handle_identity_update(void *cls, const struct UpdateMessage *um) 128handle_identity_update (void *cls, const struct UpdateMessage *um)
128{ 129{
129 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls; 130 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
130 uint16_t name_len = ntohs(um->name_len); 131 uint16_t name_len = ntohs (um->name_len);
131 const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; 132 const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
132 133
133 el->cb(el->cb_cls, &um->private_key, str); 134 el->cb (el->cb_cls, &um->private_key, str);
134 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(el); 135 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (el);
135} 136}
136 137
137 138
@@ -144,13 +145,13 @@ handle_identity_update(void *cls, const struct UpdateMessage *um)
144 * @param error error code 145 * @param error error code
145 */ 146 */
146static void 147static void
147mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 148mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
148{ 149{
149 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls; 150 struct GNUNET_IDENTITY_EgoSuffixLookup *el = cls;
150 151
151 (void)error; 152 (void) error;
152 el->cb(el->cb_cls, NULL, NULL); 153 el->cb (el->cb_cls, NULL, NULL);
153 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(el); 154 GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (el);
154} 155}
155 156
156 157
@@ -164,46 +165,48 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
164 * @return NULL on error 165 * @return NULL on error
165 */ 166 */
166struct GNUNET_IDENTITY_EgoSuffixLookup * 167struct GNUNET_IDENTITY_EgoSuffixLookup *
167GNUNET_IDENTITY_ego_lookup_by_suffix(const struct GNUNET_CONFIGURATION_Handle *cfg, 168GNUNET_IDENTITY_ego_lookup_by_suffix (const struct
168 const char *suffix, 169 GNUNET_CONFIGURATION_Handle *cfg,
169 GNUNET_IDENTITY_EgoSuffixCallback cb, 170 const char *suffix,
170 void *cb_cls) 171 GNUNET_IDENTITY_EgoSuffixCallback cb,
172 void *cb_cls)
171{ 173{
172 struct GNUNET_IDENTITY_EgoSuffixLookup *el; 174 struct GNUNET_IDENTITY_EgoSuffixLookup *el;
173 struct GNUNET_MQ_Envelope *env; 175 struct GNUNET_MQ_Envelope *env;
174 struct GNUNET_MessageHeader *req; 176 struct GNUNET_MessageHeader *req;
175 size_t nlen; 177 size_t nlen;
176 178
177 GNUNET_assert(NULL != cb); 179 GNUNET_assert (NULL != cb);
178 el = GNUNET_new(struct GNUNET_IDENTITY_EgoSuffixLookup); 180 el = GNUNET_new (struct GNUNET_IDENTITY_EgoSuffixLookup);
179 el->cb = cb; 181 el->cb = cb;
180 el->cb_cls = cb_cls; 182 el->cb_cls = cb_cls;
181 { 183 {
182 struct GNUNET_MQ_MessageHandler handlers[] = 184 struct GNUNET_MQ_MessageHandler handlers[] =
183 { GNUNET_MQ_hd_var_size(identity_result_code, 185 { GNUNET_MQ_hd_var_size (identity_result_code,
184 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, 186 GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
185 struct ResultCodeMessage, 187 struct ResultCodeMessage,
186 el), 188 el),
187 GNUNET_MQ_hd_var_size(identity_update, 189 GNUNET_MQ_hd_var_size (identity_update,
188 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, 190 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
189 struct UpdateMessage, 191 struct UpdateMessage,
190 el), 192 el),
191 GNUNET_MQ_handler_end() }; 193 GNUNET_MQ_handler_end () };
192 194
193 el->mq = 195 el->mq =
194 GNUNET_CLIENT_connect(cfg, "identity", handlers, &mq_error_handler, el); 196 GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
195 } 197 }
196 if (NULL == el->mq) 198 if (NULL == el->mq)
197 { 199 {
198 GNUNET_break(0); 200 GNUNET_break (0);
199 GNUNET_free(el); 201 GNUNET_free (el);
200 return NULL; 202 return NULL;
201 } 203 }
202 el->suffix = GNUNET_strdup(suffix); 204 el->suffix = GNUNET_strdup (suffix);
203 nlen = strlen(suffix) + 1; 205 nlen = strlen (suffix) + 1;
204 env = GNUNET_MQ_msg_extra(req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX); 206 env = GNUNET_MQ_msg_extra (req, nlen,
205 memcpy(&req[1], suffix, nlen); 207 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX);
206 GNUNET_MQ_send(el->mq, env); 208 memcpy (&req[1], suffix, nlen);
209 GNUNET_MQ_send (el->mq, env);
207 return el; 210 return el;
208} 211}
209 212
@@ -214,11 +217,12 @@ GNUNET_IDENTITY_ego_lookup_by_suffix(const struct GNUNET_CONFIGURATION_Handle *c
214 * @param el handle for lookup to abort 217 * @param el handle for lookup to abort
215 */ 218 */
216void 219void
217GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(struct GNUNET_IDENTITY_EgoSuffixLookup *el) 220GNUNET_IDENTITY_ego_lookup_by_suffix_cancel (struct
221 GNUNET_IDENTITY_EgoSuffixLookup *el)
218{ 222{
219 GNUNET_MQ_destroy(el->mq); 223 GNUNET_MQ_destroy (el->mq);
220 GNUNET_free(el->suffix); 224 GNUNET_free (el->suffix);
221 GNUNET_free(el); 225 GNUNET_free (el);
222} 226}
223 227
224 228
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 1f6ec94ee..247d09282 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -129,14 +129,16 @@ static char *allow_methods;
129/** 129/**
130 * @brief struct returned by the initialization function of the plugin 130 * @brief struct returned by the initialization function of the plugin
131 */ 131 */
132struct Plugin { 132struct Plugin
133{
133 const struct GNUNET_CONFIGURATION_Handle *cfg; 134 const struct GNUNET_CONFIGURATION_Handle *cfg;
134}; 135};
135 136
136/** 137/**
137 * The ego list 138 * The ego list
138 */ 139 */
139struct EgoEntry { 140struct EgoEntry
141{
140 /** 142 /**
141 * DLL 143 * DLL
142 */ 144 */
@@ -166,7 +168,8 @@ struct EgoEntry {
166/** 168/**
167 * The request handle 169 * The request handle
168 */ 170 */
169struct RequestHandle { 171struct RequestHandle
172{
170 /** 173 /**
171 * The data from the REST request 174 * The data from the REST request
172 */ 175 */
@@ -254,38 +257,38 @@ struct RequestHandle {
254 * @param handle Handle to clean up 257 * @param handle Handle to clean up
255 */ 258 */
256static void 259static void
257cleanup_handle(void *cls) 260cleanup_handle (void *cls)
258{ 261{
259 struct RequestHandle *handle = cls; 262 struct RequestHandle *handle = cls;
260 struct EgoEntry *ego_entry; 263 struct EgoEntry *ego_entry;
261 struct EgoEntry *ego_tmp; 264 struct EgoEntry *ego_tmp;
262 265
263 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); 266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
264 if (NULL != handle->timeout_task) 267 if (NULL != handle->timeout_task)
265 { 268 {
266 GNUNET_SCHEDULER_cancel(handle->timeout_task); 269 GNUNET_SCHEDULER_cancel (handle->timeout_task);
267 handle->timeout_task = NULL; 270 handle->timeout_task = NULL;
268 } 271 }
269 272
270 if (NULL != handle->url) 273 if (NULL != handle->url)
271 GNUNET_free(handle->url); 274 GNUNET_free (handle->url);
272 if (NULL != handle->emsg) 275 if (NULL != handle->emsg)
273 GNUNET_free(handle->emsg); 276 GNUNET_free (handle->emsg);
274 if (NULL != handle->name) 277 if (NULL != handle->name)
275 GNUNET_free(handle->name); 278 GNUNET_free (handle->name);
276 if (NULL != handle->identity_handle) 279 if (NULL != handle->identity_handle)
277 GNUNET_IDENTITY_disconnect(handle->identity_handle); 280 GNUNET_IDENTITY_disconnect (handle->identity_handle);
278 281
279 for (ego_entry = handle->ego_head; NULL != ego_entry;) 282 for (ego_entry = handle->ego_head; NULL != ego_entry;)
280 { 283 {
281 ego_tmp = ego_entry; 284 ego_tmp = ego_entry;
282 ego_entry = ego_entry->next; 285 ego_entry = ego_entry->next;
283 GNUNET_free(ego_tmp->identifier); 286 GNUNET_free (ego_tmp->identifier);
284 GNUNET_free(ego_tmp->keystring); 287 GNUNET_free (ego_tmp->keystring);
285 GNUNET_free(ego_tmp); 288 GNUNET_free (ego_tmp);
286 } 289 }
287 290
288 GNUNET_free(handle); 291 GNUNET_free (handle);
289} 292}
290 293
291/** 294/**
@@ -294,26 +297,26 @@ cleanup_handle(void *cls)
294 * @param cls the `struct RequestHandle` 297 * @param cls the `struct RequestHandle`
295 */ 298 */
296static void 299static void
297do_error(void *cls) 300do_error (void *cls)
298{ 301{
299 struct RequestHandle *handle = cls; 302 struct RequestHandle *handle = cls;
300 struct MHD_Response *resp; 303 struct MHD_Response *resp;
301 json_t *json_error = json_object(); 304 json_t *json_error = json_object ();
302 char *response; 305 char *response;
303 306
304 if (NULL == handle->emsg) 307 if (NULL == handle->emsg)
305 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_ERROR_UNKNOWN); 308 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_ERROR_UNKNOWN);
306 309
307 json_object_set_new(json_error, "error", json_string(handle->emsg)); 310 json_object_set_new (json_error, "error", json_string (handle->emsg));
308 311
309 if (0 == handle->response_code) 312 if (0 == handle->response_code)
310 handle->response_code = MHD_HTTP_OK; 313 handle->response_code = MHD_HTTP_OK;
311 response = json_dumps(json_error, 0); 314 response = json_dumps (json_error, 0);
312 resp = GNUNET_REST_create_response(response); 315 resp = GNUNET_REST_create_response (response);
313 handle->proc(handle->proc_cls, resp, handle->response_code); 316 handle->proc (handle->proc_cls, resp, handle->response_code);
314 json_decref(json_error); 317 json_decref (json_error);
315 GNUNET_free(response); 318 GNUNET_free (response);
316 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 319 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
317} 320}
318 321
319 322
@@ -327,30 +330,30 @@ do_error(void *cls)
327 * @return EgoEntry or NULL if not found 330 * @return EgoEntry or NULL if not found
328 */ 331 */
329struct EgoEntry * 332struct EgoEntry *
330get_egoentry(struct RequestHandle *handle, char *pubkey, char *name) 333get_egoentry (struct RequestHandle *handle, char *pubkey, char *name)
331{ 334{
332 struct EgoEntry *ego_entry; 335 struct EgoEntry *ego_entry;
333 336
334 if (NULL != pubkey) 337 if (NULL != pubkey)
338 {
339 for (ego_entry = handle->ego_head; NULL != ego_entry;
340 ego_entry = ego_entry->next)
335 { 341 {
336 for (ego_entry = handle->ego_head; NULL != ego_entry; 342 if (0 != strcasecmp (pubkey, ego_entry->keystring))
337 ego_entry = ego_entry->next) 343 continue;
338 { 344 return ego_entry;
339 if (0 != strcasecmp(pubkey, ego_entry->keystring))
340 continue;
341 return ego_entry;
342 }
343 } 345 }
346 }
344 if (NULL != name) 347 if (NULL != name)
348 {
349 for (ego_entry = handle->ego_head; NULL != ego_entry;
350 ego_entry = ego_entry->next)
345 { 351 {
346 for (ego_entry = handle->ego_head; NULL != ego_entry; 352 if (0 != strcasecmp (name, ego_entry->identifier))
347 ego_entry = ego_entry->next) 353 continue;
348 { 354 return ego_entry;
349 if (0 != strcasecmp(name, ego_entry->identifier))
350 continue;
351 return ego_entry;
352 }
353 } 355 }
356 }
354 return NULL; 357 return NULL;
355} 358}
356 359
@@ -364,10 +367,10 @@ get_egoentry(struct RequestHandle *handle, char *pubkey, char *name)
364 * @param name the id of the ego 367 * @param name the id of the ego
365 */ 368 */
366static void 369static void
367ego_get_for_subsystem(void *cls, 370ego_get_for_subsystem (void *cls,
368 struct GNUNET_IDENTITY_Ego *ego, 371 struct GNUNET_IDENTITY_Ego *ego,
369 void **ctx, 372 void **ctx,
370 const char *name) 373 const char *name)
371{ 374{
372 struct RequestHandle *handle = cls; 375 struct RequestHandle *handle = cls;
373 struct MHD_Response *resp; 376 struct MHD_Response *resp;
@@ -377,34 +380,34 @@ ego_get_for_subsystem(void *cls,
377 char *public_key_string; 380 char *public_key_string;
378 381
379 if (NULL == ego) 382 if (NULL == ego)
380 { 383 {
381 handle->response_code = MHD_HTTP_NOT_FOUND; 384 handle->response_code = MHD_HTTP_NOT_FOUND;
382 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 385 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
383 GNUNET_SCHEDULER_add_now(&do_error, handle); 386 GNUNET_SCHEDULER_add_now (&do_error, handle);
384 return; 387 return;
385 } 388 }
386 389
387 GNUNET_IDENTITY_ego_get_public_key(ego, &public_key); 390 GNUNET_IDENTITY_ego_get_public_key (ego, &public_key);
388 public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string(&public_key); 391 public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string (&public_key);
389 392
390 // create json with subsystem identity 393 // create json with subsystem identity
391 json_root = json_object(); 394 json_root = json_object ();
392 json_object_set_new(json_root, 395 json_object_set_new (json_root,
393 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 396 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
394 json_string(public_key_string)); 397 json_string (public_key_string));
395 json_object_set_new(json_root, 398 json_object_set_new (json_root,
396 GNUNET_REST_IDENTITY_PARAM_NAME, 399 GNUNET_REST_IDENTITY_PARAM_NAME,
397 json_string(name)); 400 json_string (name));
398 401
399 result_str = json_dumps(json_root, 0); 402 result_str = json_dumps (json_root, 0);
400 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
401 resp = GNUNET_REST_create_response(result_str); 404 resp = GNUNET_REST_create_response (result_str);
402 405
403 json_decref(json_root); 406 json_decref (json_root);
404 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 407 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
405 GNUNET_free(result_str); 408 GNUNET_free (result_str);
406 GNUNET_free(public_key_string); 409 GNUNET_free (public_key_string);
407 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 410 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
408} 411}
409 412
410/** 413/**
@@ -415,35 +418,35 @@ ego_get_for_subsystem(void *cls,
415 * @param cls the RequestHandle 418 * @param cls the RequestHandle
416 */ 419 */
417void 420void
418ego_get_subsystem(struct GNUNET_REST_RequestHandle *con_handle, 421ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
419 const char *url, 422 const char *url,
420 void *cls) 423 void *cls)
421{ 424{
422 struct RequestHandle *handle = cls; 425 struct RequestHandle *handle = cls;
423 char *subsystem; 426 char *subsystem;
424 427
425 if (strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen(handle->url)) 428 if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
426 { 429 {
427 handle->emsg = GNUNET_strdup("Missing subsystem name"); 430 handle->emsg = GNUNET_strdup ("Missing subsystem name");
428 GNUNET_SCHEDULER_add_now(&do_error, handle); 431 GNUNET_SCHEDULER_add_now (&do_error, handle);
429 return; 432 return;
430 } 433 }
431 subsystem = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; 434 subsystem = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
432 //requested default identity of subsystem 435 // requested default identity of subsystem
433 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem); 436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem);
434 437
435 handle->op = GNUNET_IDENTITY_get(handle->identity_handle, 438 handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
436 subsystem, 439 subsystem,
437 &ego_get_for_subsystem, 440 &ego_get_for_subsystem,
438 handle); 441 handle);
439 442
440 if (NULL == handle->op) 443 if (NULL == handle->op)
441 { 444 {
442 handle->response_code = MHD_HTTP_NOT_FOUND; 445 handle->response_code = MHD_HTTP_NOT_FOUND;
443 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 446 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
444 GNUNET_SCHEDULER_add_now(&do_error, handle); 447 GNUNET_SCHEDULER_add_now (&do_error, handle);
445 return; 448 return;
446 } 449 }
447} 450}
448 451
449 452
@@ -455,9 +458,9 @@ ego_get_subsystem(struct GNUNET_REST_RequestHandle *con_handle,
455 * @param cls the RequestHandle 458 * @param cls the RequestHandle
456 */ 459 */
457void 460void
458ego_get_all(struct GNUNET_REST_RequestHandle *con_handle, 461ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
459 const char *url, 462 const char *url,
460 void *cls) 463 void *cls)
461{ 464{
462 struct RequestHandle *handle = cls; 465 struct RequestHandle *handle = cls;
463 struct EgoEntry *ego_entry; 466 struct EgoEntry *ego_entry;
@@ -466,30 +469,30 @@ ego_get_all(struct GNUNET_REST_RequestHandle *con_handle,
466 json_t *json_ego; 469 json_t *json_ego;
467 char *result_str; 470 char *result_str;
468 471
469 json_root = json_array(); 472 json_root = json_array ();
470 //Return ego/egos 473 // Return ego/egos
471 for (ego_entry = handle->ego_head; NULL != ego_entry; 474 for (ego_entry = handle->ego_head; NULL != ego_entry;
472 ego_entry = ego_entry->next) 475 ego_entry = ego_entry->next)
473 { 476 {
474 json_ego = json_object(); 477 json_ego = json_object ();
475 json_object_set_new(json_ego, 478 json_object_set_new (json_ego,
476 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 479 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
477 json_string(ego_entry->keystring)); 480 json_string (ego_entry->keystring));
478 json_object_set_new(json_ego, 481 json_object_set_new (json_ego,
479 GNUNET_REST_IDENTITY_PARAM_NAME, 482 GNUNET_REST_IDENTITY_PARAM_NAME,
480 json_string(ego_entry->identifier)); 483 json_string (ego_entry->identifier));
481 json_array_append(json_root, json_ego); 484 json_array_append (json_root, json_ego);
482 json_decref(json_ego); 485 json_decref (json_ego);
483 } 486 }
484 487
485 result_str = json_dumps(json_root, 0); 488 result_str = json_dumps (json_root, 0);
486 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
487 resp = GNUNET_REST_create_response(result_str); 490 resp = GNUNET_REST_create_response (result_str);
488 491
489 json_decref(json_root); 492 json_decref (json_root);
490 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 493 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
491 GNUNET_free(result_str); 494 GNUNET_free (result_str);
492 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 495 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
493} 496}
494 497
495 498
@@ -500,28 +503,28 @@ ego_get_all(struct GNUNET_REST_RequestHandle *con_handle,
500 * @param ego_entry the struct EgoEntry for the response 503 * @param ego_entry the struct EgoEntry for the response
501 */ 504 */
502void 505void
503ego_get_response(struct RequestHandle *handle, struct EgoEntry *ego_entry) 506ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
504{ 507{
505 struct MHD_Response *resp; 508 struct MHD_Response *resp;
506 json_t *json_ego; 509 json_t *json_ego;
507 char *result_str; 510 char *result_str;
508 511
509 json_ego = json_object(); 512 json_ego = json_object ();
510 json_object_set_new(json_ego, 513 json_object_set_new (json_ego,
511 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 514 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
512 json_string(ego_entry->keystring)); 515 json_string (ego_entry->keystring));
513 json_object_set_new(json_ego, 516 json_object_set_new (json_ego,
514 GNUNET_REST_IDENTITY_PARAM_NAME, 517 GNUNET_REST_IDENTITY_PARAM_NAME,
515 json_string(ego_entry->identifier)); 518 json_string (ego_entry->identifier));
516 519
517 result_str = json_dumps(json_ego, 0); 520 result_str = json_dumps (json_ego, 0);
518 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
519 resp = GNUNET_REST_create_response(result_str); 522 resp = GNUNET_REST_create_response (result_str);
520 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 523 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
521 524
522 json_decref(json_ego); 525 json_decref (json_ego);
523 GNUNET_free(result_str); 526 GNUNET_free (result_str);
524 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 527 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
525} 528}
526 529
527 530
@@ -533,9 +536,9 @@ ego_get_response(struct RequestHandle *handle, struct EgoEntry *ego_entry)
533 * @param cls the RequestHandle 536 * @param cls the RequestHandle
534 */ 537 */
535void 538void
536ego_get_pubkey(struct GNUNET_REST_RequestHandle *con_handle, 539ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
537 const char *url, 540 const char *url,
538 void *cls) 541 void *cls)
539{ 542{
540 struct RequestHandle *handle = cls; 543 struct RequestHandle *handle = cls;
541 struct EgoEntry *ego_entry; 544 struct EgoEntry *ego_entry;
@@ -543,25 +546,25 @@ ego_get_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
543 546
544 keystring = NULL; 547 keystring = NULL;
545 548
546 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url)) 549 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
547 { 550 {
548 handle->response_code = MHD_HTTP_NOT_FOUND; 551 handle->response_code = MHD_HTTP_NOT_FOUND;
549 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); 552 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
550 GNUNET_SCHEDULER_add_now(&do_error, handle); 553 GNUNET_SCHEDULER_add_now (&do_error, handle);
551 return; 554 return;
552 } 555 }
553 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 556 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
554 ego_entry = get_egoentry(handle, keystring, NULL); 557 ego_entry = get_egoentry (handle, keystring, NULL);
555 558
556 if (NULL == ego_entry) 559 if (NULL == ego_entry)
557 { 560 {
558 handle->response_code = MHD_HTTP_NOT_FOUND; 561 handle->response_code = MHD_HTTP_NOT_FOUND;
559 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 562 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
560 GNUNET_SCHEDULER_add_now(&do_error, handle); 563 GNUNET_SCHEDULER_add_now (&do_error, handle);
561 return; 564 return;
562 } 565 }
563 566
564 ego_get_response(handle, ego_entry); 567 ego_get_response (handle, ego_entry);
565} 568}
566 569
567/** 570/**
@@ -572,9 +575,9 @@ ego_get_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
572 * @param cls the RequestHandle 575 * @param cls the RequestHandle
573 */ 576 */
574void 577void
575ego_get_name(struct GNUNET_REST_RequestHandle *con_handle, 578ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
576 const char *url, 579 const char *url,
577 void *cls) 580 void *cls)
578{ 581{
579 struct RequestHandle *handle = cls; 582 struct RequestHandle *handle = cls;
580 struct EgoEntry *ego_entry; 583 struct EgoEntry *ego_entry;
@@ -582,25 +585,25 @@ ego_get_name(struct GNUNET_REST_RequestHandle *con_handle,
582 585
583 egoname = NULL; 586 egoname = NULL;
584 587
585 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url)) 588 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
586 { 589 {
587 handle->response_code = MHD_HTTP_NOT_FOUND; 590 handle->response_code = MHD_HTTP_NOT_FOUND;
588 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); 591 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
589 GNUNET_SCHEDULER_add_now(&do_error, handle); 592 GNUNET_SCHEDULER_add_now (&do_error, handle);
590 return; 593 return;
591 } 594 }
592 egoname = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 595 egoname = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
593 ego_entry = get_egoentry(handle, NULL, egoname); 596 ego_entry = get_egoentry (handle, NULL, egoname);
594 597
595 if (NULL == ego_entry) 598 if (NULL == ego_entry)
596 { 599 {
597 handle->response_code = MHD_HTTP_NOT_FOUND; 600 handle->response_code = MHD_HTTP_NOT_FOUND;
598 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 601 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
599 GNUNET_SCHEDULER_add_now(&do_error, handle); 602 GNUNET_SCHEDULER_add_now (&do_error, handle);
600 return; 603 return;
601 } 604 }
602 605
603 ego_get_response(handle, ego_entry); 606 ego_get_response (handle, ego_entry);
604} 607}
605 608
606 609
@@ -611,25 +614,25 @@ ego_get_name(struct GNUNET_REST_RequestHandle *con_handle,
611 * @param emsg error message 614 * @param emsg error message
612 */ 615 */
613static void 616static void
614do_finished(void *cls, const char *emsg) 617do_finished (void *cls, const char *emsg)
615{ 618{
616 struct RequestHandle *handle = cls; 619 struct RequestHandle *handle = cls;
617 struct MHD_Response *resp; 620 struct MHD_Response *resp;
618 621
619 handle->op = NULL; 622 handle->op = NULL;
620 if (NULL != emsg) 623 if (NULL != emsg)
621 { 624 {
622 handle->emsg = GNUNET_strdup(emsg); 625 handle->emsg = GNUNET_strdup (emsg);
623 GNUNET_SCHEDULER_add_now(&do_error, handle); 626 GNUNET_SCHEDULER_add_now (&do_error, handle);
624 return; 627 return;
625 } 628 }
626 if (0 == handle->response_code) 629 if (0 == handle->response_code)
627 { 630 {
628 handle->response_code = MHD_HTTP_NO_CONTENT; 631 handle->response_code = MHD_HTTP_NO_CONTENT;
629 } 632 }
630 resp = GNUNET_REST_create_response(NULL); 633 resp = GNUNET_REST_create_response (NULL);
631 handle->proc(handle->proc_cls, resp, handle->response_code); 634 handle->proc (handle->proc_cls, resp, handle->response_code);
632 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 635 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
633} 636}
634 637
635 638
@@ -641,14 +644,14 @@ do_finished(void *cls, const char *emsg)
641 * @param emsg error message 644 * @param emsg error message
642 */ 645 */
643static void 646static void
644do_finished_create(void *cls, 647do_finished_create (void *cls,
645 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 648 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
646 const char *emsg) 649 const char *emsg)
647{ 650{
648 struct RequestHandle *handle = cls; 651 struct RequestHandle *handle = cls;
649 652
650 (void)pk; 653 (void) pk;
651 do_finished(handle, emsg); 654 do_finished (handle, emsg);
652} 655}
653 656
654 657
@@ -659,7 +662,7 @@ do_finished_create(void *cls,
659 * @param ego_entry the struct EgoEntry we want to edit 662 * @param ego_entry the struct EgoEntry we want to edit
660 */ 663 */
661void 664void
662ego_edit(struct RequestHandle *handle, struct EgoEntry *ego_entry) 665ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry)
663{ 666{
664 struct EgoEntry *ego_entry_tmp; 667 struct EgoEntry *ego_entry_tmp;
665 struct MHD_Response *resp; 668 struct MHD_Response *resp;
@@ -669,80 +672,80 @@ ego_edit(struct RequestHandle *handle, struct EgoEntry *ego_entry)
669 char term_data[handle->data_size + 1]; 672 char term_data[handle->data_size + 1];
670 int json_state; 673 int json_state;
671 674
672 //if no data 675 // if no data
673 if (0 >= handle->data_size) 676 if (0 >= handle->data_size)
674 { 677 {
675 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 678 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
676 GNUNET_SCHEDULER_add_now(&do_error, handle); 679 GNUNET_SCHEDULER_add_now (&do_error, handle);
677 return; 680 return;
678 } 681 }
679 //if not json 682 // if not json
680 term_data[handle->data_size] = '\0'; 683 term_data[handle->data_size] = '\0';
681 GNUNET_memcpy(term_data, handle->data, handle->data_size); 684 GNUNET_memcpy (term_data, handle->data, handle->data_size);
682 data_js = json_loads(term_data, JSON_DECODE_ANY, &err); 685 data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
683 686
684 if (NULL == data_js) 687 if (NULL == data_js)
685 { 688 {
686 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 689 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
687 GNUNET_SCHEDULER_add_now(&do_error, handle); 690 GNUNET_SCHEDULER_add_now (&do_error, handle);
688 return; 691 return;
689 } 692 }
690 693
691 newname = NULL; 694 newname = NULL;
692 //NEW NAME 695 // NEW NAME
693 json_state = 0; 696 json_state = 0;
694 json_state = json_unpack(data_js, 697 json_state = json_unpack (data_js,
695 "{s:s!}", 698 "{s:s!}",
696 GNUNET_REST_IDENTITY_PARAM_NEWNAME, 699 GNUNET_REST_IDENTITY_PARAM_NEWNAME,
697 &newname); 700 &newname);
698 //Change name with pubkey or name identifier 701 // Change name with pubkey or name identifier
699 if (0 != json_state) 702 if (0 != json_state)
700 { 703 {
701 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 704 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
702 GNUNET_SCHEDULER_add_now(&do_error, handle); 705 GNUNET_SCHEDULER_add_now (&do_error, handle);
703 json_decref(data_js); 706 json_decref (data_js);
704 return; 707 return;
705 } 708 }
706 709
707 if (NULL == newname) 710 if (NULL == newname)
708 { 711 {
709 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 712 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
710 GNUNET_SCHEDULER_add_now(&do_error, handle); 713 GNUNET_SCHEDULER_add_now (&do_error, handle);
711 json_decref(data_js); 714 json_decref (data_js);
712 return; 715 return;
713 } 716 }
714 717
715 if (0 >= strlen(newname)) 718 if (0 >= strlen (newname))
716 { 719 {
717 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 720 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
718 GNUNET_SCHEDULER_add_now(&do_error, handle); 721 GNUNET_SCHEDULER_add_now (&do_error, handle);
719 json_decref(data_js); 722 json_decref (data_js);
720 return; 723 return;
721 } 724 }
722 725
723 ego_entry_tmp = get_egoentry(handle, NULL, newname); 726 ego_entry_tmp = get_egoentry (handle, NULL, newname);
724 if (NULL != ego_entry_tmp) 727 if (NULL != ego_entry_tmp)
725 { 728 {
726 //Ego with same name not allowed (even if its the ego we change) 729 // Ego with same name not allowed (even if its the ego we change)
727 resp = GNUNET_REST_create_response(NULL); 730 resp = GNUNET_REST_create_response (NULL);
728 handle->proc(handle->proc_cls, resp, MHD_HTTP_CONFLICT); 731 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
729 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 732 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
730 json_decref(data_js); 733 json_decref (data_js);
731 return; 734 return;
732 } 735 }
733 handle->op = GNUNET_IDENTITY_rename(handle->identity_handle, 736 handle->op = GNUNET_IDENTITY_rename (handle->identity_handle,
734 ego_entry->identifier, 737 ego_entry->identifier,
735 newname, 738 newname,
736 &do_finished, 739 &do_finished,
737 handle); 740 handle);
738 if (NULL == handle->op) 741 if (NULL == handle->op)
739 { 742 {
740 handle->emsg = GNUNET_strdup("Rename failed"); 743 handle->emsg = GNUNET_strdup ("Rename failed");
741 GNUNET_SCHEDULER_add_now(&do_error, handle); 744 GNUNET_SCHEDULER_add_now (&do_error, handle);
742 json_decref(data_js); 745 json_decref (data_js);
743 return; 746 return;
744 } 747 }
745 json_decref(data_js); 748 json_decref (data_js);
746 return; 749 return;
747} 750}
748 751
@@ -755,9 +758,9 @@ ego_edit(struct RequestHandle *handle, struct EgoEntry *ego_entry)
755 * @param cls the RequestHandle 758 * @param cls the RequestHandle
756 */ 759 */
757void 760void
758ego_edit_pubkey(struct GNUNET_REST_RequestHandle *con_handle, 761ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
759 const char *url, 762 const char *url,
760 void *cls) 763 void *cls)
761{ 764{
762 struct RequestHandle *handle = cls; 765 struct RequestHandle *handle = cls;
763 struct EgoEntry *ego_entry; 766 struct EgoEntry *ego_entry;
@@ -765,25 +768,25 @@ ego_edit_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
765 768
766 keystring = NULL; 769 keystring = NULL;
767 770
768 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url)) 771 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
769 { 772 {
770 handle->response_code = MHD_HTTP_NOT_FOUND; 773 handle->response_code = MHD_HTTP_NOT_FOUND;
771 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); 774 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
772 GNUNET_SCHEDULER_add_now(&do_error, handle); 775 GNUNET_SCHEDULER_add_now (&do_error, handle);
773 return; 776 return;
774 } 777 }
775 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 778 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
776 ego_entry = get_egoentry(handle, keystring, NULL); 779 ego_entry = get_egoentry (handle, keystring, NULL);
777 780
778 if (NULL == ego_entry) 781 if (NULL == ego_entry)
779 { 782 {
780 handle->response_code = MHD_HTTP_NOT_FOUND; 783 handle->response_code = MHD_HTTP_NOT_FOUND;
781 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 784 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
782 GNUNET_SCHEDULER_add_now(&do_error, handle); 785 GNUNET_SCHEDULER_add_now (&do_error, handle);
783 return; 786 return;
784 } 787 }
785 788
786 ego_edit(handle, ego_entry); 789 ego_edit (handle, ego_entry);
787} 790}
788 791
789/** 792/**
@@ -794,9 +797,9 @@ ego_edit_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
794 * @param cls the RequestHandle 797 * @param cls the RequestHandle
795 */ 798 */
796void 799void
797ego_edit_name(struct GNUNET_REST_RequestHandle *con_handle, 800ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
798 const char *url, 801 const char *url,
799 void *cls) 802 void *cls)
800{ 803{
801 struct RequestHandle *handle = cls; 804 struct RequestHandle *handle = cls;
802 struct EgoEntry *ego_entry; 805 struct EgoEntry *ego_entry;
@@ -804,25 +807,25 @@ ego_edit_name(struct GNUNET_REST_RequestHandle *con_handle,
804 807
805 name = NULL; 808 name = NULL;
806 809
807 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url)) 810 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
808 { 811 {
809 handle->response_code = MHD_HTTP_NOT_FOUND; 812 handle->response_code = MHD_HTTP_NOT_FOUND;
810 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); 813 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
811 GNUNET_SCHEDULER_add_now(&do_error, handle); 814 GNUNET_SCHEDULER_add_now (&do_error, handle);
812 return; 815 return;
813 } 816 }
814 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 817 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
815 ego_entry = get_egoentry(handle, NULL, name); 818 ego_entry = get_egoentry (handle, NULL, name);
816 819
817 if (NULL == ego_entry) 820 if (NULL == ego_entry)
818 { 821 {
819 handle->response_code = MHD_HTTP_NOT_FOUND; 822 handle->response_code = MHD_HTTP_NOT_FOUND;
820 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 823 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
821 GNUNET_SCHEDULER_add_now(&do_error, handle); 824 GNUNET_SCHEDULER_add_now (&do_error, handle);
822 return; 825 return;
823 } 826 }
824 827
825 ego_edit(handle, ego_entry); 828 ego_edit (handle, ego_entry);
826} 829}
827 830
828/** 831/**
@@ -833,9 +836,9 @@ ego_edit_name(struct GNUNET_REST_RequestHandle *con_handle,
833 * @param cls the RequestHandle 836 * @param cls the RequestHandle
834 */ 837 */
835void 838void
836ego_edit_subsystem(struct GNUNET_REST_RequestHandle *con_handle, 839ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
837 const char *url, 840 const char *url,
838 void *cls) 841 void *cls)
839{ 842{
840 struct RequestHandle *handle = cls; 843 struct RequestHandle *handle = cls;
841 struct EgoEntry *ego_entry; 844 struct EgoEntry *ego_entry;
@@ -848,88 +851,88 @@ ego_edit_subsystem(struct GNUNET_REST_RequestHandle *con_handle,
848 851
849 name = NULL; 852 name = NULL;
850 853
851 if (strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen(handle->url)) 854 if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
852 { 855 {
853 handle->response_code = MHD_HTTP_NOT_FOUND; 856 handle->response_code = MHD_HTTP_NOT_FOUND;
854 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); 857 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
855 GNUNET_SCHEDULER_add_now(&do_error, handle); 858 GNUNET_SCHEDULER_add_now (&do_error, handle);
856 return; 859 return;
857 } 860 }
858 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; 861 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
859 ego_entry = get_egoentry(handle, NULL, name); 862 ego_entry = get_egoentry (handle, NULL, name);
860 863
861 if (NULL == ego_entry) 864 if (NULL == ego_entry)
862 { 865 {
863 handle->response_code = MHD_HTTP_NOT_FOUND; 866 handle->response_code = MHD_HTTP_NOT_FOUND;
864 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 867 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
865 GNUNET_SCHEDULER_add_now(&do_error, handle); 868 GNUNET_SCHEDULER_add_now (&do_error, handle);
866 return; 869 return;
867 } 870 }
868 871
869 //if no data 872 // if no data
870 if (0 >= handle->data_size) 873 if (0 >= handle->data_size)
871 { 874 {
872 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 875 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
873 GNUNET_SCHEDULER_add_now(&do_error, handle); 876 GNUNET_SCHEDULER_add_now (&do_error, handle);
874 return; 877 return;
875 } 878 }
876 //if not json 879 // if not json
877 term_data[handle->data_size] = '\0'; 880 term_data[handle->data_size] = '\0';
878 GNUNET_memcpy(term_data, handle->data, handle->data_size); 881 GNUNET_memcpy (term_data, handle->data, handle->data_size);
879 data_js = json_loads(term_data, JSON_DECODE_ANY, &err); 882 data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
880 883
881 if (NULL == data_js) 884 if (NULL == data_js)
882 { 885 {
883 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 886 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
884 GNUNET_SCHEDULER_add_now(&do_error, handle); 887 GNUNET_SCHEDULER_add_now (&do_error, handle);
885 return; 888 return;
886 } 889 }
887 890
888 newsubsys = NULL; 891 newsubsys = NULL;
889 //SUBSYSTEM 892 // SUBSYSTEM
890 json_state = 0; 893 json_state = 0;
891 json_state = json_unpack(data_js, 894 json_state = json_unpack (data_js,
892 "{s:s!}", 895 "{s:s!}",
893 GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM, 896 GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM,
894 &newsubsys); 897 &newsubsys);
895 //Change subsystem with pubkey or name identifier 898 // Change subsystem with pubkey or name identifier
896 if (0 != json_state) 899 if (0 != json_state)
897 { 900 {
898 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 901 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
899 GNUNET_SCHEDULER_add_now(&do_error, handle); 902 GNUNET_SCHEDULER_add_now (&do_error, handle);
900 json_decref(data_js); 903 json_decref (data_js);
901 return; 904 return;
902 } 905 }
903 906
904 if (NULL == newsubsys) 907 if (NULL == newsubsys)
905 { 908 {
906 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 909 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
907 GNUNET_SCHEDULER_add_now(&do_error, handle); 910 GNUNET_SCHEDULER_add_now (&do_error, handle);
908 json_decref(data_js); 911 json_decref (data_js);
909 return; 912 return;
910 } 913 }
911 914
912 if (0 >= strlen(newsubsys)) 915 if (0 >= strlen (newsubsys))
913 { 916 {
914 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 917 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
915 GNUNET_SCHEDULER_add_now(&do_error, handle); 918 GNUNET_SCHEDULER_add_now (&do_error, handle);
916 json_decref(data_js); 919 json_decref (data_js);
917 return; 920 return;
918 } 921 }
919 922
920 handle->response_code = MHD_HTTP_NO_CONTENT; 923 handle->response_code = MHD_HTTP_NO_CONTENT;
921 handle->op = GNUNET_IDENTITY_set(handle->identity_handle, 924 handle->op = GNUNET_IDENTITY_set (handle->identity_handle,
922 newsubsys, 925 newsubsys,
923 ego_entry->ego, 926 ego_entry->ego,
924 &do_finished, 927 &do_finished,
925 handle); 928 handle);
926 if (NULL == handle->op) 929 if (NULL == handle->op)
927 { 930 {
928 handle->emsg = GNUNET_strdup("Setting subsystem failed"); 931 handle->emsg = GNUNET_strdup ("Setting subsystem failed");
929 GNUNET_SCHEDULER_add_now(&do_error, handle); 932 GNUNET_SCHEDULER_add_now (&do_error, handle);
930 return; 933 return;
931 } 934 }
932 json_decref(data_js); 935 json_decref (data_js);
933 return; 936 return;
934} 937}
935 938
@@ -941,9 +944,9 @@ ego_edit_subsystem(struct GNUNET_REST_RequestHandle *con_handle,
941 * @param cls the RequestHandle 944 * @param cls the RequestHandle
942 */ 945 */
943void 946void
944ego_create(struct GNUNET_REST_RequestHandle *con_handle, 947ego_create (struct GNUNET_REST_RequestHandle *con_handle,
945 const char *url, 948 const char *url,
946 void *cls) 949 void *cls)
947{ 950{
948 struct RequestHandle *handle = cls; 951 struct RequestHandle *handle = cls;
949 struct EgoEntry *ego_entry; 952 struct EgoEntry *ego_entry;
@@ -954,73 +957,73 @@ ego_create(struct GNUNET_REST_RequestHandle *con_handle,
954 int json_unpack_state; 957 int json_unpack_state;
955 char term_data[handle->data_size + 1]; 958 char term_data[handle->data_size + 1];
956 959
957 if (strlen(GNUNET_REST_API_NS_IDENTITY) != strlen(handle->url)) 960 if (strlen (GNUNET_REST_API_NS_IDENTITY) != strlen (handle->url))
958 { 961 {
959 GNUNET_SCHEDULER_add_now(&do_error, handle); 962 GNUNET_SCHEDULER_add_now (&do_error, handle);
960 return; 963 return;
961 } 964 }
962 965
963 if (0 >= handle->data_size) 966 if (0 >= handle->data_size)
964 { 967 {
965 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 968 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
966 GNUNET_SCHEDULER_add_now(&do_error, handle); 969 GNUNET_SCHEDULER_add_now (&do_error, handle);
967 return; 970 return;
968 } 971 }
969 term_data[handle->data_size] = '\0'; 972 term_data[handle->data_size] = '\0';
970 GNUNET_memcpy(term_data, handle->data, handle->data_size); 973 GNUNET_memcpy (term_data, handle->data, handle->data_size);
971 data_js = json_loads(term_data, JSON_DECODE_ANY, &err); 974 data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
972 if (NULL == data_js) 975 if (NULL == data_js)
973 { 976 {
974 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); 977 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
975 GNUNET_SCHEDULER_add_now(&do_error, handle); 978 GNUNET_SCHEDULER_add_now (&do_error, handle);
976 json_decref(data_js); 979 json_decref (data_js);
977 return; 980 return;
978 } 981 }
979 json_unpack_state = 0; 982 json_unpack_state = 0;
980 json_unpack_state = 983 json_unpack_state =
981 json_unpack(data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname); 984 json_unpack (data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname);
982 if (0 != json_unpack_state) 985 if (0 != json_unpack_state)
983 { 986 {
984 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 987 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
985 GNUNET_SCHEDULER_add_now(&do_error, handle); 988 GNUNET_SCHEDULER_add_now (&do_error, handle);
986 json_decref(data_js); 989 json_decref (data_js);
987 return; 990 return;
988 } 991 }
989 992
990 if (NULL == egoname) 993 if (NULL == egoname)
991 { 994 {
992 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 995 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
993 GNUNET_SCHEDULER_add_now(&do_error, handle); 996 GNUNET_SCHEDULER_add_now (&do_error, handle);
994 json_decref(data_js); 997 json_decref (data_js);
995 return; 998 return;
996 } 999 }
997 if (0 >= strlen(egoname)) 1000 if (0 >= strlen (egoname))
998 { 1001 {
999 json_decref(data_js); 1002 json_decref (data_js);
1000 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); 1003 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
1001 GNUNET_SCHEDULER_add_now(&do_error, handle); 1004 GNUNET_SCHEDULER_add_now (&do_error, handle);
1002 return; 1005 return;
1003 } 1006 }
1004 GNUNET_STRINGS_utf8_tolower(egoname, egoname); 1007 GNUNET_STRINGS_utf8_tolower (egoname, egoname);
1005 for (ego_entry = handle->ego_head; NULL != ego_entry; 1008 for (ego_entry = handle->ego_head; NULL != ego_entry;
1006 ego_entry = ego_entry->next) 1009 ego_entry = ego_entry->next)
1010 {
1011 if (0 == strcasecmp (egoname, ego_entry->identifier))
1007 { 1012 {
1008 if (0 == strcasecmp(egoname, ego_entry->identifier)) 1013 resp = GNUNET_REST_create_response (NULL);
1009 { 1014 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
1010 resp = GNUNET_REST_create_response(NULL); 1015 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
1011 handle->proc(handle->proc_cls, resp, MHD_HTTP_CONFLICT); 1016 json_decref (data_js);
1012 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 1017 return;
1013 json_decref(data_js);
1014 return;
1015 }
1016 } 1018 }
1017 handle->name = GNUNET_strdup(egoname); 1019 }
1018 json_decref(data_js); 1020 handle->name = GNUNET_strdup (egoname);
1021 json_decref (data_js);
1019 handle->response_code = MHD_HTTP_CREATED; 1022 handle->response_code = MHD_HTTP_CREATED;
1020 handle->op = GNUNET_IDENTITY_create(handle->identity_handle, 1023 handle->op = GNUNET_IDENTITY_create (handle->identity_handle,
1021 handle->name, 1024 handle->name,
1022 &do_finished_create, 1025 &do_finished_create,
1023 handle); 1026 handle);
1024} 1027}
1025 1028
1026/** 1029/**
@@ -1031,9 +1034,9 @@ ego_create(struct GNUNET_REST_RequestHandle *con_handle,
1031 * @param cls the RequestHandle 1034 * @param cls the RequestHandle
1032 */ 1035 */
1033void 1036void
1034ego_delete_pubkey(struct GNUNET_REST_RequestHandle *con_handle, 1037ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
1035 const char *url, 1038 const char *url,
1036 void *cls) 1039 void *cls)
1037{ 1040{
1038 struct RequestHandle *handle = cls; 1041 struct RequestHandle *handle = cls;
1039 struct EgoEntry *ego_entry; 1042 struct EgoEntry *ego_entry;
@@ -1041,29 +1044,29 @@ ego_delete_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
1041 1044
1042 keystring = NULL; 1045 keystring = NULL;
1043 1046
1044 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url)) 1047 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
1045 { 1048 {
1046 handle->response_code = MHD_HTTP_NOT_FOUND; 1049 handle->response_code = MHD_HTTP_NOT_FOUND;
1047 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); 1050 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
1048 GNUNET_SCHEDULER_add_now(&do_error, handle); 1051 GNUNET_SCHEDULER_add_now (&do_error, handle);
1049 return; 1052 return;
1050 } 1053 }
1051 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 1054 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
1052 ego_entry = get_egoentry(handle, keystring, NULL); 1055 ego_entry = get_egoentry (handle, keystring, NULL);
1053 1056
1054 if (NULL == ego_entry) 1057 if (NULL == ego_entry)
1055 { 1058 {
1056 handle->response_code = MHD_HTTP_NOT_FOUND; 1059 handle->response_code = MHD_HTTP_NOT_FOUND;
1057 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 1060 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1058 GNUNET_SCHEDULER_add_now(&do_error, handle); 1061 GNUNET_SCHEDULER_add_now (&do_error, handle);
1059 return; 1062 return;
1060 } 1063 }
1061 1064
1062 handle->response_code = MHD_HTTP_NO_CONTENT; 1065 handle->response_code = MHD_HTTP_NO_CONTENT;
1063 handle->op = GNUNET_IDENTITY_delete(handle->identity_handle, 1066 handle->op = GNUNET_IDENTITY_delete (handle->identity_handle,
1064 ego_entry->identifier, 1067 ego_entry->identifier,
1065 &do_finished, 1068 &do_finished,
1066 handle); 1069 handle);
1067} 1070}
1068 1071
1069 1072
@@ -1075,9 +1078,9 @@ ego_delete_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
1075 * @param cls the RequestHandle 1078 * @param cls the RequestHandle
1076 */ 1079 */
1077void 1080void
1078ego_delete_name(struct GNUNET_REST_RequestHandle *con_handle, 1081ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
1079 const char *url, 1082 const char *url,
1080 void *cls) 1083 void *cls)
1081{ 1084{
1082 struct RequestHandle *handle = cls; 1085 struct RequestHandle *handle = cls;
1083 struct EgoEntry *ego_entry; 1086 struct EgoEntry *ego_entry;
@@ -1085,29 +1088,29 @@ ego_delete_name(struct GNUNET_REST_RequestHandle *con_handle,
1085 1088
1086 name = NULL; 1089 name = NULL;
1087 1090
1088 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url)) 1091 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
1089 { 1092 {
1090 handle->response_code = MHD_HTTP_NOT_FOUND; 1093 handle->response_code = MHD_HTTP_NOT_FOUND;
1091 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); 1094 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
1092 GNUNET_SCHEDULER_add_now(&do_error, handle); 1095 GNUNET_SCHEDULER_add_now (&do_error, handle);
1093 return; 1096 return;
1094 } 1097 }
1095 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 1098 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
1096 ego_entry = get_egoentry(handle, NULL, name); 1099 ego_entry = get_egoentry (handle, NULL, name);
1097 1100
1098 if (NULL == ego_entry) 1101 if (NULL == ego_entry)
1099 { 1102 {
1100 handle->response_code = MHD_HTTP_NOT_FOUND; 1103 handle->response_code = MHD_HTTP_NOT_FOUND;
1101 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); 1104 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
1102 GNUNET_SCHEDULER_add_now(&do_error, handle); 1105 GNUNET_SCHEDULER_add_now (&do_error, handle);
1103 return; 1106 return;
1104 } 1107 }
1105 1108
1106 handle->response_code = MHD_HTTP_NO_CONTENT; 1109 handle->response_code = MHD_HTTP_NO_CONTENT;
1107 handle->op = GNUNET_IDENTITY_delete(handle->identity_handle, 1110 handle->op = GNUNET_IDENTITY_delete (handle->identity_handle,
1108 ego_entry->identifier, 1111 ego_entry->identifier,
1109 &do_finished, 1112 &do_finished,
1110 handle); 1113 handle);
1111} 1114}
1112 1115
1113 1116
@@ -1119,18 +1122,18 @@ ego_delete_name(struct GNUNET_REST_RequestHandle *con_handle,
1119 * @param cls the RequestHandle 1122 * @param cls the RequestHandle
1120 */ 1123 */
1121static void 1124static void
1122options_cont(struct GNUNET_REST_RequestHandle *con_handle, 1125options_cont (struct GNUNET_REST_RequestHandle *con_handle,
1123 const char *url, 1126 const char *url,
1124 void *cls) 1127 void *cls)
1125{ 1128{
1126 struct MHD_Response *resp; 1129 struct MHD_Response *resp;
1127 struct RequestHandle *handle = cls; 1130 struct RequestHandle *handle = cls;
1128 1131
1129 //For now, independent of path return all options 1132 // For now, independent of path return all options
1130 resp = GNUNET_REST_create_response(NULL); 1133 resp = GNUNET_REST_create_response (NULL);
1131 MHD_add_response_header(resp, "Access-Control-Allow-Methods", allow_methods); 1134 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
1132 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); 1135 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1133 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); 1136 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
1134 return; 1137 return;
1135} 1138}
1136 1139
@@ -1140,39 +1143,40 @@ options_cont(struct GNUNET_REST_RequestHandle *con_handle,
1140 * @param handle the request handle 1143 * @param handle the request handle
1141 */ 1144 */
1142static void 1145static void
1143init_cont(struct RequestHandle *handle) 1146init_cont (struct RequestHandle *handle)
1144{ 1147{
1145 struct GNUNET_REST_RequestHandlerError err; 1148 struct GNUNET_REST_RequestHandlerError err;
1146 static const struct GNUNET_REST_RequestHandler handlers[] = 1149 static const struct GNUNET_REST_RequestHandler handlers[] =
1147 { { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ALL, &ego_get_all }, 1150 { { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ALL, &ego_get_all },
1148 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey }, 1151 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1152 &ego_get_pubkey },
1149 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name }, 1153 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name },
1150 { MHD_HTTP_METHOD_GET, 1154 { MHD_HTTP_METHOD_GET,
1151 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, 1155 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
1152 &ego_get_subsystem }, 1156 &ego_get_subsystem },
1153 { MHD_HTTP_METHOD_PUT, 1157 { MHD_HTTP_METHOD_PUT,
1154 GNUNET_REST_API_NS_IDENTITY_PUBKEY, 1158 GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1155 &ego_edit_pubkey }, 1159 &ego_edit_pubkey },
1156 { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name }, 1160 { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name },
1157 { MHD_HTTP_METHOD_PUT, 1161 { MHD_HTTP_METHOD_PUT,
1158 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, 1162 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
1159 &ego_edit_subsystem }, 1163 &ego_edit_subsystem },
1160 { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create }, 1164 { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create },
1161 { MHD_HTTP_METHOD_DELETE, 1165 { MHD_HTTP_METHOD_DELETE,
1162 GNUNET_REST_API_NS_IDENTITY_PUBKEY, 1166 GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1163 &ego_delete_pubkey }, 1167 &ego_delete_pubkey },
1164 { MHD_HTTP_METHOD_DELETE, 1168 { MHD_HTTP_METHOD_DELETE,
1165 GNUNET_REST_API_NS_IDENTITY_NAME, 1169 GNUNET_REST_API_NS_IDENTITY_NAME,
1166 &ego_delete_name }, 1170 &ego_delete_name },
1167 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont }, 1171 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont },
1168 GNUNET_REST_HANDLER_END }; 1172 GNUNET_REST_HANDLER_END };
1169 1173
1170 if (GNUNET_NO == 1174 if (GNUNET_NO ==
1171 GNUNET_REST_handle_request(handle->rest_handle, handlers, &err, handle)) 1175 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1172 { 1176 {
1173 handle->response_code = err.error_code; 1177 handle->response_code = err.error_code;
1174 GNUNET_SCHEDULER_add_now(&do_error, handle); 1178 GNUNET_SCHEDULER_add_now (&do_error, handle);
1175 } 1179 }
1176} 1180}
1177 1181
1178/** 1182/**
@@ -1209,32 +1213,32 @@ init_cont(struct RequestHandle *handle)
1209 * must thus no longer be used 1213 * must thus no longer be used
1210 */ 1214 */
1211static void 1215static void
1212init_egos(void *cls, 1216init_egos (void *cls,
1213 struct GNUNET_IDENTITY_Ego *ego, 1217 struct GNUNET_IDENTITY_Ego *ego,
1214 void **ctx, 1218 void **ctx,
1215 const char *identifier) 1219 const char *identifier)
1216{ 1220{
1217 struct RequestHandle *handle = cls; 1221 struct RequestHandle *handle = cls;
1218 struct EgoEntry *ego_entry; 1222 struct EgoEntry *ego_entry;
1219 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 1223 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
1220 1224
1221 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) 1225 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1222 { 1226 {
1223 handle->state = ID_REST_STATE_POST_INIT; 1227 handle->state = ID_REST_STATE_POST_INIT;
1224 init_cont(handle); 1228 init_cont (handle);
1225 return; 1229 return;
1226 } 1230 }
1227 if (ID_REST_STATE_INIT == handle->state) 1231 if (ID_REST_STATE_INIT == handle->state)
1228 { 1232 {
1229 ego_entry = GNUNET_new(struct EgoEntry); 1233 ego_entry = GNUNET_new (struct EgoEntry);
1230 GNUNET_IDENTITY_ego_get_public_key(ego, &pk); 1234 GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
1231 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pk); 1235 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
1232 ego_entry->ego = ego; 1236 ego_entry->ego = ego;
1233 GNUNET_asprintf(&ego_entry->identifier, "%s", identifier); 1237 GNUNET_asprintf (&ego_entry->identifier, "%s", identifier);
1234 GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head, 1238 GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head,
1235 handle->ego_tail, 1239 handle->ego_tail,
1236 ego_entry); 1240 ego_entry);
1237 } 1241 }
1238} 1242}
1239 1243
1240/** 1244/**
@@ -1249,11 +1253,11 @@ init_egos(void *cls,
1249 * @return GNUNET_OK if request accepted 1253 * @return GNUNET_OK if request accepted
1250 */ 1254 */
1251static void 1255static void
1252rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, 1256rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1253 GNUNET_REST_ResultProcessor proc, 1257 GNUNET_REST_ResultProcessor proc,
1254 void *proc_cls) 1258 void *proc_cls)
1255{ 1259{
1256 struct RequestHandle *handle = GNUNET_new(struct RequestHandle); 1260 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1257 1261
1258 handle->response_code = 0; 1262 handle->response_code = 0;
1259 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1263 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1263,17 +1267,17 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
1263 handle->data = rest_handle->data; 1267 handle->data = rest_handle->data;
1264 handle->data_size = rest_handle->data_size; 1268 handle->data_size = rest_handle->data_size;
1265 1269
1266 handle->url = GNUNET_strdup(rest_handle->url); 1270 handle->url = GNUNET_strdup (rest_handle->url);
1267 if (handle->url[strlen(handle->url) - 1] == '/') 1271 if (handle->url[strlen (handle->url) - 1] == '/')
1268 handle->url[strlen(handle->url) - 1] = '\0'; 1272 handle->url[strlen (handle->url) - 1] = '\0';
1269 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); 1273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1270 1274
1271 handle->identity_handle = GNUNET_IDENTITY_connect(cfg, &init_egos, handle); 1275 handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &init_egos, handle);
1272 1276
1273 handle->timeout_task = 1277 handle->timeout_task =
1274 GNUNET_SCHEDULER_add_delayed(handle->timeout, &do_error, handle); 1278 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
1275 1279
1276 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); 1280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1277} 1281}
1278 1282
1279/** 1283/**
@@ -1283,7 +1287,7 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
1283 * @return NULL on error, otherwise the plugin context 1287 * @return NULL on error, otherwise the plugin context
1284 */ 1288 */
1285void * 1289void *
1286libgnunet_plugin_rest_identity_init(void *cls) 1290libgnunet_plugin_rest_identity_init (void *cls)
1287{ 1291{
1288 static struct Plugin plugin; 1292 static struct Plugin plugin;
1289 struct GNUNET_REST_Plugin *api; 1293 struct GNUNET_REST_Plugin *api;
@@ -1291,21 +1295,21 @@ libgnunet_plugin_rest_identity_init(void *cls)
1291 cfg = cls; 1295 cfg = cls;
1292 if (NULL != plugin.cfg) 1296 if (NULL != plugin.cfg)
1293 return NULL; /* can only initialize once! */ 1297 return NULL; /* can only initialize once! */
1294 memset(&plugin, 0, sizeof(struct Plugin)); 1298 memset (&plugin, 0, sizeof(struct Plugin));
1295 plugin.cfg = cfg; 1299 plugin.cfg = cfg;
1296 api = GNUNET_new(struct GNUNET_REST_Plugin); 1300 api = GNUNET_new (struct GNUNET_REST_Plugin);
1297 api->cls = &plugin; 1301 api->cls = &plugin;
1298 api->name = GNUNET_REST_API_NS_IDENTITY; 1302 api->name = GNUNET_REST_API_NS_IDENTITY;
1299 api->process_request = &rest_process_request; 1303 api->process_request = &rest_process_request;
1300 GNUNET_asprintf(&allow_methods, 1304 GNUNET_asprintf (&allow_methods,
1301 "%s, %s, %s, %s, %s", 1305 "%s, %s, %s, %s, %s",
1302 MHD_HTTP_METHOD_GET, 1306 MHD_HTTP_METHOD_GET,
1303 MHD_HTTP_METHOD_POST, 1307 MHD_HTTP_METHOD_POST,
1304 MHD_HTTP_METHOD_PUT, 1308 MHD_HTTP_METHOD_PUT,
1305 MHD_HTTP_METHOD_DELETE, 1309 MHD_HTTP_METHOD_DELETE,
1306 MHD_HTTP_METHOD_OPTIONS); 1310 MHD_HTTP_METHOD_OPTIONS);
1307 1311
1308 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Identity REST API initialized\n")); 1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n"));
1309 return api; 1313 return api;
1310} 1314}
1311 1315
@@ -1316,18 +1320,17 @@ libgnunet_plugin_rest_identity_init(void *cls)
1316 * @return always NULL 1320 * @return always NULL
1317 */ 1321 */
1318void * 1322void *
1319libgnunet_plugin_rest_identity_done(void *cls) 1323libgnunet_plugin_rest_identity_done (void *cls)
1320{ 1324{
1321 struct GNUNET_REST_Plugin *api = cls; 1325 struct GNUNET_REST_Plugin *api = cls;
1322 struct Plugin *plugin = api->cls; 1326 struct Plugin *plugin = api->cls;
1323 1327
1324 plugin->cfg = NULL; 1328 plugin->cfg = NULL;
1325 1329
1326 GNUNET_free_non_null(allow_methods); 1330 GNUNET_free_non_null (allow_methods);
1327 GNUNET_free(api); 1331 GNUNET_free (api);
1328 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n"); 1332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n");
1329 return NULL; 1333 return NULL;
1330} 1334}
1331 1335
1332/* end of plugin_rest_identity.c */ 1336/* end of plugin_rest_identity.c */
1333
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c
index 7f7371422..aaa435d4f 100644
--- a/src/identity/test_identity.c
+++ b/src/identity/test_identity.c
@@ -29,7 +29,7 @@
29#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
30 30
31 31
32#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
33 33
34 34
35/** 35/**
@@ -54,33 +54,33 @@ static struct GNUNET_SCHEDULER_Task *endbadly_task;
54 54
55#define CHECK(cond) \ 55#define CHECK(cond) \
56 do \ 56 do \
57 { \ 57 { \
58 if (!(cond)) \ 58 if (! (cond)) \
59 { \ 59 { \
60 GNUNET_break(0); \ 60 GNUNET_break (0); \
61 end(); \ 61 end (); \
62 return; \ 62 return; \
63 } \ 63 } \
64 } while (0) 64 } while (0)
65 65
66 66
67/** 67/**
68 * Clean up all resources used. 68 * Clean up all resources used.
69 */ 69 */
70static void 70static void
71cleanup(void *cls) 71cleanup (void *cls)
72{ 72{
73 (void)cls; 73 (void) cls;
74 if (NULL != op) 74 if (NULL != op)
75 { 75 {
76 GNUNET_IDENTITY_cancel(op); 76 GNUNET_IDENTITY_cancel (op);
77 op = NULL; 77 op = NULL;
78 } 78 }
79 if (NULL != h) 79 if (NULL != h)
80 { 80 {
81 GNUNET_IDENTITY_disconnect(h); 81 GNUNET_IDENTITY_disconnect (h);
82 h = NULL; 82 h = NULL;
83 } 83 }
84} 84}
85 85
86 86
@@ -90,9 +90,9 @@ cleanup(void *cls)
90 * @param cls NULL 90 * @param cls NULL
91 */ 91 */
92static void 92static void
93endbadly(void *cls) 93endbadly (void *cls)
94{ 94{
95 GNUNET_SCHEDULER_shutdown(); 95 GNUNET_SCHEDULER_shutdown ();
96} 96}
97 97
98 98
@@ -100,14 +100,14 @@ endbadly(void *cls)
100 * Finish the testcase (successfully). 100 * Finish the testcase (successfully).
101 */ 101 */
102static void 102static void
103end() 103end ()
104{ 104{
105 if (NULL != endbadly_task) 105 if (NULL != endbadly_task)
106 { 106 {
107 GNUNET_SCHEDULER_cancel(endbadly_task); 107 GNUNET_SCHEDULER_cancel (endbadly_task);
108 endbadly_task = NULL; 108 endbadly_task = NULL;
109 } 109 }
110 GNUNET_SCHEDULER_shutdown(); 110 GNUNET_SCHEDULER_shutdown ();
111} 111}
112 112
113 113
@@ -123,64 +123,64 @@ end()
123 * must thus no longer be used 123 * must thus no longer be used
124 */ 124 */
125static void 125static void
126notification_cb(void *cls, 126notification_cb (void *cls,
127 struct GNUNET_IDENTITY_Ego *ego, 127 struct GNUNET_IDENTITY_Ego *ego,
128 void **ctx, 128 void **ctx,
129 const char *identifier) 129 const char *identifier)
130{ 130{
131 static struct GNUNET_IDENTITY_Ego *my_ego; 131 static struct GNUNET_IDENTITY_Ego *my_ego;
132 static int round; 132 static int round;
133 133
134 switch (round) 134 switch (round)
135 { 135 {
136 case 0: /* end of initial iteration */ 136 case 0: /* end of initial iteration */
137 CHECK(NULL == ego); 137 CHECK (NULL == ego);
138 CHECK(NULL == identifier); 138 CHECK (NULL == identifier);
139 break; 139 break;
140 140
141 case 1: /* create */ 141 case 1: /* create */
142 CHECK(NULL != ego); 142 CHECK (NULL != ego);
143 CHECK(NULL != identifier); 143 CHECK (NULL != identifier);
144 CHECK(0 == strcmp(identifier, "test-id")); 144 CHECK (0 == strcmp (identifier, "test-id"));
145 my_ego = ego; 145 my_ego = ego;
146 *ctx = &round; 146 *ctx = &round;
147 break; 147 break;
148 148
149 case 2: /* rename */ 149 case 2: /* rename */
150 CHECK(my_ego == ego); 150 CHECK (my_ego == ego);
151 CHECK(NULL != identifier); 151 CHECK (NULL != identifier);
152 CHECK(0 == strcmp(identifier, "test")); 152 CHECK (0 == strcmp (identifier, "test"));
153 CHECK(*ctx == &round); 153 CHECK (*ctx == &round);
154 break; 154 break;
155 155
156 case 3: /* reconnect-down */ 156 case 3: /* reconnect-down */
157 CHECK(my_ego == ego); 157 CHECK (my_ego == ego);
158 CHECK(NULL == identifier); 158 CHECK (NULL == identifier);
159 CHECK(*ctx == &round); 159 CHECK (*ctx == &round);
160 *ctx = NULL; 160 *ctx = NULL;
161 break; 161 break;
162 162
163 case 4: /* reconnect-up */ 163 case 4: /* reconnect-up */
164 CHECK(NULL != identifier); 164 CHECK (NULL != identifier);
165 CHECK(0 == strcmp(identifier, "test")); 165 CHECK (0 == strcmp (identifier, "test"));
166 my_ego = ego; 166 my_ego = ego;
167 *ctx = &round; 167 *ctx = &round;
168 break; 168 break;
169 169
170 case 5: /* end of iteration after reconnect */ 170 case 5: /* end of iteration after reconnect */
171 CHECK(NULL == ego); 171 CHECK (NULL == ego);
172 CHECK(NULL == identifier); 172 CHECK (NULL == identifier);
173 break; 173 break;
174 174
175 case 6: /* delete */ 175 case 6: /* delete */
176 CHECK(my_ego == ego); 176 CHECK (my_ego == ego);
177 CHECK(*ctx == &round); 177 CHECK (*ctx == &round);
178 *ctx = NULL; 178 *ctx = NULL;
179 break; 179 break;
180 180
181 default: 181 default:
182 CHECK(0); 182 CHECK (0);
183 } 183 }
184 round++; 184 round++;
185} 185}
186 186
@@ -192,12 +192,12 @@ notification_cb(void *cls,
192 * @param emsg (should also be NULL) 192 * @param emsg (should also be NULL)
193 */ 193 */
194static void 194static void
195delete_cont(void *cls, const char *emsg) 195delete_cont (void *cls, const char *emsg)
196{ 196{
197 op = NULL; 197 op = NULL;
198 CHECK(NULL == emsg); 198 CHECK (NULL == emsg);
199 res = 0; 199 res = 0;
200 end(); 200 end ();
201} 201}
202 202
203 203
@@ -207,9 +207,9 @@ delete_cont(void *cls, const char *emsg)
207 * @param cls NULL 207 * @param cls NULL
208 */ 208 */
209static void 209static void
210finally_delete(void *cls) 210finally_delete (void *cls)
211{ 211{
212 op = GNUNET_IDENTITY_delete(h, "test", &delete_cont, NULL); 212 op = GNUNET_IDENTITY_delete (h, "test", &delete_cont, NULL);
213} 213}
214 214
215 215
@@ -220,13 +220,13 @@ finally_delete(void *cls)
220 * @param emsg (should also be NULL) 220 * @param emsg (should also be NULL)
221 */ 221 */
222static void 222static void
223fail_rename_cont(void *cls, const char *emsg) 223fail_rename_cont (void *cls, const char *emsg)
224{ 224{
225 CHECK(NULL != emsg); 225 CHECK (NULL != emsg);
226 op = NULL; 226 op = NULL;
227 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, 227 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
228 &finally_delete, 228 &finally_delete,
229 NULL); 229 NULL);
230} 230}
231 231
232 232
@@ -237,10 +237,10 @@ fail_rename_cont(void *cls, const char *emsg)
237 * @param emsg (should also be NULL) 237 * @param emsg (should also be NULL)
238 */ 238 */
239static void 239static void
240success_rename_cont(void *cls, const char *emsg) 240success_rename_cont (void *cls, const char *emsg)
241{ 241{
242 CHECK(NULL == emsg); 242 CHECK (NULL == emsg);
243 op = GNUNET_IDENTITY_rename(h, "test-id", "test", &fail_rename_cont, NULL); 243 op = GNUNET_IDENTITY_rename (h, "test-id", "test", &fail_rename_cont, NULL);
244} 244}
245 245
246 246
@@ -252,14 +252,14 @@ success_rename_cont(void *cls, const char *emsg)
252 * @param emsg error message 252 * @param emsg error message
253 */ 253 */
254static void 254static void
255create_cb(void *cls, 255create_cb (void *cls,
256 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 256 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
257 const char *emsg) 257 const char *emsg)
258{ 258{
259 CHECK(NULL != pk); 259 CHECK (NULL != pk);
260 CHECK(NULL == emsg); 260 CHECK (NULL == emsg);
261 op = 261 op =
262 GNUNET_IDENTITY_rename(h, "test-id", "test", &success_rename_cont, NULL); 262 GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL);
263} 263}
264 264
265 265
@@ -271,30 +271,30 @@ create_cb(void *cls,
271 * @param peer handle to access more of the peer (not used) 271 * @param peer handle to access more of the peer (not used)
272 */ 272 */
273static void 273static void
274run(void *cls, 274run (void *cls,
275 const struct GNUNET_CONFIGURATION_Handle *cfg, 275 const struct GNUNET_CONFIGURATION_Handle *cfg,
276 struct GNUNET_TESTING_Peer *peer) 276 struct GNUNET_TESTING_Peer *peer)
277{ 277{
278 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL); 278 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
279 GNUNET_SCHEDULER_add_shutdown(&cleanup, NULL); 279 GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
280 h = GNUNET_IDENTITY_connect(cfg, &notification_cb, NULL); 280 h = GNUNET_IDENTITY_connect (cfg, &notification_cb, NULL);
281 CHECK(NULL != h); 281 CHECK (NULL != h);
282 op = GNUNET_IDENTITY_create(h, "test-id", &create_cb, NULL); 282 op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
283} 283}
284 284
285 285
286int 286int
287main(int argc, char *argv[]) 287main (int argc, char *argv[])
288{ 288{
289 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service"); 289 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
290 res = 1; 290 res = 1;
291 if (0 != GNUNET_TESTING_service_run("test-identity", 291 if (0 != GNUNET_TESTING_service_run ("test-identity",
292 "identity", 292 "identity",
293 "test_identity.conf", 293 "test_identity.conf",
294 &run, 294 &run,
295 NULL)) 295 NULL))
296 return 1; 296 return 1;
297 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service"); 297 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
298 return res; 298 return res;
299} 299}
300 300
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c
index 6e14022c6..1dd05f1b9 100644
--- a/src/identity/test_identity_defaults.c
+++ b/src/identity/test_identity_defaults.c
@@ -29,7 +29,7 @@
29#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
30 30
31 31
32#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) 32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
33 33
34 34
35/** 35/**
@@ -54,33 +54,33 @@ static struct GNUNET_SCHEDULER_Task *endbadly_task;
54 54
55#define CHECK(cond) \ 55#define CHECK(cond) \
56 do \ 56 do \
57 { \ 57 { \
58 if (!(cond)) \ 58 if (! (cond)) \
59 { \ 59 { \
60 GNUNET_break(0); \ 60 GNUNET_break (0); \
61 end(); \ 61 end (); \
62 return; \ 62 return; \
63 } \ 63 } \
64 } while (0) 64 } while (0)
65 65
66 66
67/** 67/**
68 * Clean up all resources used. 68 * Clean up all resources used.
69 */ 69 */
70static void 70static void
71cleanup(void *cls) 71cleanup (void *cls)
72{ 72{
73 (void)cls; 73 (void) cls;
74 if (NULL != op) 74 if (NULL != op)
75 { 75 {
76 GNUNET_IDENTITY_cancel(op); 76 GNUNET_IDENTITY_cancel (op);
77 op = NULL; 77 op = NULL;
78 } 78 }
79 if (NULL != h) 79 if (NULL != h)
80 { 80 {
81 GNUNET_IDENTITY_disconnect(h); 81 GNUNET_IDENTITY_disconnect (h);
82 h = NULL; 82 h = NULL;
83 } 83 }
84} 84}
85 85
86 86
@@ -90,9 +90,9 @@ cleanup(void *cls)
90 * @param cls NULL 90 * @param cls NULL
91 */ 91 */
92static void 92static void
93endbadly(void *cls) 93endbadly (void *cls)
94{ 94{
95 GNUNET_SCHEDULER_shutdown(); 95 GNUNET_SCHEDULER_shutdown ();
96 res = 1; 96 res = 1;
97} 97}
98 98
@@ -101,14 +101,14 @@ endbadly(void *cls)
101 * Termiante the testcase. 101 * Termiante the testcase.
102 */ 102 */
103static void 103static void
104end() 104end ()
105{ 105{
106 if (NULL != endbadly_task) 106 if (NULL != endbadly_task)
107 { 107 {
108 GNUNET_SCHEDULER_cancel(endbadly_task); 108 GNUNET_SCHEDULER_cancel (endbadly_task);
109 endbadly_task = NULL; 109 endbadly_task = NULL;
110 } 110 }
111 GNUNET_SCHEDULER_shutdown(); 111 GNUNET_SCHEDULER_shutdown ();
112} 112}
113 113
114 114
@@ -119,12 +119,12 @@ end()
119 * @param emsg (should also be NULL) 119 * @param emsg (should also be NULL)
120 */ 120 */
121static void 121static void
122delete_cont(void *cls, const char *emsg) 122delete_cont (void *cls, const char *emsg)
123{ 123{
124 op = NULL; 124 op = NULL;
125 CHECK(NULL == emsg); 125 CHECK (NULL == emsg);
126 res = 0; 126 res = 0;
127 end(); 127 end ();
128} 128}
129 129
130 130
@@ -135,16 +135,16 @@ delete_cont(void *cls, const char *emsg)
135 * @param emsg (should also be NULL) 135 * @param emsg (should also be NULL)
136 */ 136 */
137static void 137static void
138get_cb(void *cls, 138get_cb (void *cls,
139 struct GNUNET_IDENTITY_Ego *ego, 139 struct GNUNET_IDENTITY_Ego *ego,
140 void **ctx, 140 void **ctx,
141 const char *identifier) 141 const char *identifier)
142{ 142{
143 op = NULL; 143 op = NULL;
144 CHECK(NULL != ego); 144 CHECK (NULL != ego);
145 CHECK(NULL != identifier); 145 CHECK (NULL != identifier);
146 CHECK(0 == strcmp(identifier, "test-id")); 146 CHECK (0 == strcmp (identifier, "test-id"));
147 op = GNUNET_IDENTITY_delete(h, "test-id", &delete_cont, NULL); 147 op = GNUNET_IDENTITY_delete (h, "test-id", &delete_cont, NULL);
148} 148}
149 149
150 150
@@ -160,15 +160,15 @@ get_cb(void *cls,
160 * must thus no longer be used 160 * must thus no longer be used
161 */ 161 */
162static void 162static void
163dummy_cb(void *cls, 163dummy_cb (void *cls,
164 struct GNUNET_IDENTITY_Ego *ego, 164 struct GNUNET_IDENTITY_Ego *ego,
165 void **ctx, 165 void **ctx,
166 const char *identifier) 166 const char *identifier)
167{ 167{
168 (void)cls; 168 (void) cls;
169 (void)ego; 169 (void) ego;
170 (void)ctx; 170 (void) ctx;
171 (void)identifier; 171 (void) identifier;
172} 172}
173 173
174 174
@@ -180,15 +180,15 @@ dummy_cb(void *cls,
180 * @param peer handle to access more of the peer (not used) 180 * @param peer handle to access more of the peer (not used)
181 */ 181 */
182static void 182static void
183run_get(void *cls, 183run_get (void *cls,
184 const struct GNUNET_CONFIGURATION_Handle *cfg, 184 const struct GNUNET_CONFIGURATION_Handle *cfg,
185 struct GNUNET_TESTING_Peer *peer) 185 struct GNUNET_TESTING_Peer *peer)
186{ 186{
187 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL); 187 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
188 GNUNET_SCHEDULER_add_shutdown(&cleanup, NULL); 188 GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
189 h = GNUNET_IDENTITY_connect(cfg, &dummy_cb, NULL); 189 h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL);
190 CHECK(NULL != h); 190 CHECK (NULL != h);
191 op = GNUNET_IDENTITY_get(h, "test-service", &get_cb, NULL); 191 op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL);
192} 192}
193 193
194 194
@@ -199,11 +199,11 @@ run_get(void *cls,
199 * @param emsg (should also be NULL) 199 * @param emsg (should also be NULL)
200 */ 200 */
201static void 201static void
202success_set_cont(void *cls, const char *emsg) 202success_set_cont (void *cls, const char *emsg)
203{ 203{
204 op = NULL; 204 op = NULL;
205 CHECK(NULL == emsg); 205 CHECK (NULL == emsg);
206 end(); 206 end ();
207} 207}
208 208
209 209
@@ -219,16 +219,16 @@ success_set_cont(void *cls, const char *emsg)
219 * must thus no longer be used 219 * must thus no longer be used
220 */ 220 */
221static void 221static void
222notification_cb(void *cls, 222notification_cb (void *cls,
223 struct GNUNET_IDENTITY_Ego *ego, 223 struct GNUNET_IDENTITY_Ego *ego,
224 void **ctx, 224 void **ctx,
225 const char *identifier) 225 const char *identifier)
226{ 226{
227 if (NULL == ego) 227 if (NULL == ego)
228 return; /* skip first call */ 228 return; /* skip first call */
229 if (NULL == identifier) 229 if (NULL == identifier)
230 return; /* deletion / shutdown */ 230 return; /* deletion / shutdown */
231 op = GNUNET_IDENTITY_set(h, "test-service", ego, &success_set_cont, NULL); 231 op = GNUNET_IDENTITY_set (h, "test-service", ego, &success_set_cont, NULL);
232} 232}
233 233
234 234
@@ -240,12 +240,12 @@ notification_cb(void *cls,
240 * @param emsg error message 240 * @param emsg error message
241 */ 241 */
242static void 242static void
243create_cb(void *cls, 243create_cb (void *cls,
244 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 244 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
245 const char *emsg) 245 const char *emsg)
246{ 246{
247 CHECK(NULL == emsg); 247 CHECK (NULL == emsg);
248 CHECK(NULL != pk); 248 CHECK (NULL != pk);
249 op = NULL; 249 op = NULL;
250} 250}
251 251
@@ -258,36 +258,36 @@ create_cb(void *cls,
258 * @param peer handle to access more of the peer (not used) 258 * @param peer handle to access more of the peer (not used)
259 */ 259 */
260static void 260static void
261run_set(void *cls, 261run_set (void *cls,
262 const struct GNUNET_CONFIGURATION_Handle *cfg, 262 const struct GNUNET_CONFIGURATION_Handle *cfg,
263 struct GNUNET_TESTING_Peer *peer) 263 struct GNUNET_TESTING_Peer *peer)
264{ 264{
265 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL); 265 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
266 GNUNET_SCHEDULER_add_shutdown(&cleanup, NULL); 266 GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
267 h = GNUNET_IDENTITY_connect(cfg, &notification_cb, NULL); 267 h = GNUNET_IDENTITY_connect (cfg, &notification_cb, NULL);
268 CHECK(NULL != h); 268 CHECK (NULL != h);
269 op = GNUNET_IDENTITY_create(h, "test-id", &create_cb, NULL); 269 op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
270} 270}
271 271
272 272
273int 273int
274main(int argc, char *argv[]) 274main (int argc, char *argv[])
275{ 275{
276 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service"); 276 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
277 res = 1; 277 res = 1;
278 if (0 != GNUNET_TESTING_service_run("test-identity-defaults", 278 if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
279 "identity", 279 "identity",
280 "test_identity.conf", 280 "test_identity.conf",
281 &run_set, 281 &run_set,
282 NULL)) 282 NULL))
283 return 1; 283 return 1;
284 if (0 != GNUNET_TESTING_service_run("test-identity-defaults", 284 if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
285 "identity", 285 "identity",
286 "test_identity.conf", 286 "test_identity.conf",
287 &run_get, 287 &run_get,
288 NULL)) 288 NULL))
289 return 1; 289 return 1;
290 GNUNET_DISK_directory_remove("/tmp/gnunet/test-identity-service"); 290 GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
291 return res; 291 return res;
292} 292}
293 293