aboutsummaryrefslogtreecommitdiff
path: root/src/identity/plugin_rest_identity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r--src/identity/plugin_rest_identity.c1090
1 files changed, 544 insertions, 546 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index ac1965a75..1f6ec94ee 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 GNUnet e.V. 3 Copyright (C) 2012-2015 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -129,16 +129,14 @@ 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{
134 const struct GNUNET_CONFIGURATION_Handle *cfg; 133 const struct GNUNET_CONFIGURATION_Handle *cfg;
135}; 134};
136 135
137/** 136/**
138 * The ego list 137 * The ego list
139 */ 138 */
140struct EgoEntry 139struct EgoEntry {
141{
142 /** 140 /**
143 * DLL 141 * DLL
144 */ 142 */
@@ -168,8 +166,7 @@ struct EgoEntry
168/** 166/**
169 * The request handle 167 * The request handle
170 */ 168 */
171struct RequestHandle 169struct RequestHandle {
172{
173 /** 170 /**
174 * The data from the REST request 171 * The data from the REST request
175 */ 172 */
@@ -257,38 +254,38 @@ struct RequestHandle
257 * @param handle Handle to clean up 254 * @param handle Handle to clean up
258 */ 255 */
259static void 256static void
260cleanup_handle (void *cls) 257cleanup_handle(void *cls)
261{ 258{
262 struct RequestHandle *handle = cls; 259 struct RequestHandle *handle = cls;
263 struct EgoEntry *ego_entry; 260 struct EgoEntry *ego_entry;
264 struct EgoEntry *ego_tmp; 261 struct EgoEntry *ego_tmp;
265 262
266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); 263 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
267 if (NULL != handle->timeout_task) 264 if (NULL != handle->timeout_task)
268 { 265 {
269 GNUNET_SCHEDULER_cancel (handle->timeout_task); 266 GNUNET_SCHEDULER_cancel(handle->timeout_task);
270 handle->timeout_task = NULL; 267 handle->timeout_task = NULL;
271 } 268 }
272 269
273 if (NULL != handle->url) 270 if (NULL != handle->url)
274 GNUNET_free (handle->url); 271 GNUNET_free(handle->url);
275 if (NULL != handle->emsg) 272 if (NULL != handle->emsg)
276 GNUNET_free (handle->emsg); 273 GNUNET_free(handle->emsg);
277 if (NULL != handle->name) 274 if (NULL != handle->name)
278 GNUNET_free (handle->name); 275 GNUNET_free(handle->name);
279 if (NULL != handle->identity_handle) 276 if (NULL != handle->identity_handle)
280 GNUNET_IDENTITY_disconnect (handle->identity_handle); 277 GNUNET_IDENTITY_disconnect(handle->identity_handle);
281 278
282 for (ego_entry = handle->ego_head; NULL != ego_entry;) 279 for (ego_entry = handle->ego_head; NULL != ego_entry;)
283 { 280 {
284 ego_tmp = ego_entry; 281 ego_tmp = ego_entry;
285 ego_entry = ego_entry->next; 282 ego_entry = ego_entry->next;
286 GNUNET_free (ego_tmp->identifier); 283 GNUNET_free(ego_tmp->identifier);
287 GNUNET_free (ego_tmp->keystring); 284 GNUNET_free(ego_tmp->keystring);
288 GNUNET_free (ego_tmp); 285 GNUNET_free(ego_tmp);
289 } 286 }
290 287
291 GNUNET_free (handle); 288 GNUNET_free(handle);
292} 289}
293 290
294/** 291/**
@@ -297,26 +294,26 @@ cleanup_handle (void *cls)
297 * @param cls the `struct RequestHandle` 294 * @param cls the `struct RequestHandle`
298 */ 295 */
299static void 296static void
300do_error (void *cls) 297do_error(void *cls)
301{ 298{
302 struct RequestHandle *handle = cls; 299 struct RequestHandle *handle = cls;
303 struct MHD_Response *resp; 300 struct MHD_Response *resp;
304 json_t *json_error = json_object (); 301 json_t *json_error = json_object();
305 char *response; 302 char *response;
306 303
307 if (NULL == handle->emsg) 304 if (NULL == handle->emsg)
308 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_ERROR_UNKNOWN); 305 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_ERROR_UNKNOWN);
309 306
310 json_object_set_new (json_error, "error", json_string (handle->emsg)); 307 json_object_set_new(json_error, "error", json_string(handle->emsg));
311 308
312 if (0 == handle->response_code) 309 if (0 == handle->response_code)
313 handle->response_code = MHD_HTTP_OK; 310 handle->response_code = MHD_HTTP_OK;
314 response = json_dumps (json_error, 0); 311 response = json_dumps(json_error, 0);
315 resp = GNUNET_REST_create_response (response); 312 resp = GNUNET_REST_create_response(response);
316 handle->proc (handle->proc_cls, resp, handle->response_code); 313 handle->proc(handle->proc_cls, resp, handle->response_code);
317 json_decref (json_error); 314 json_decref(json_error);
318 GNUNET_free (response); 315 GNUNET_free(response);
319 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 316 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
320} 317}
321 318
322 319
@@ -330,29 +327,30 @@ do_error (void *cls)
330 * @return EgoEntry or NULL if not found 327 * @return EgoEntry or NULL if not found
331 */ 328 */
332struct EgoEntry * 329struct EgoEntry *
333get_egoentry (struct RequestHandle *handle, char *pubkey, char *name) 330get_egoentry(struct RequestHandle *handle, char *pubkey, char *name)
334{ 331{
335 struct EgoEntry *ego_entry; 332 struct EgoEntry *ego_entry;
333
336 if (NULL != pubkey) 334 if (NULL != pubkey)
337 {
338 for (ego_entry = handle->ego_head; NULL != ego_entry;
339 ego_entry = ego_entry->next)
340 { 335 {
341 if (0 != strcasecmp (pubkey, ego_entry->keystring)) 336 for (ego_entry = handle->ego_head; NULL != ego_entry;
342 continue; 337 ego_entry = ego_entry->next)
343 return ego_entry; 338 {
339 if (0 != strcasecmp(pubkey, ego_entry->keystring))
340 continue;
341 return ego_entry;
342 }
344 } 343 }
345 }
346 if (NULL != name) 344 if (NULL != name)
347 {
348 for (ego_entry = handle->ego_head; NULL != ego_entry;
349 ego_entry = ego_entry->next)
350 { 345 {
351 if (0 != strcasecmp (name, ego_entry->identifier)) 346 for (ego_entry = handle->ego_head; NULL != ego_entry;
352 continue; 347 ego_entry = ego_entry->next)
353 return ego_entry; 348 {
349 if (0 != strcasecmp(name, ego_entry->identifier))
350 continue;
351 return ego_entry;
352 }
354 } 353 }
355 }
356 return NULL; 354 return NULL;
357} 355}
358 356
@@ -366,10 +364,10 @@ get_egoentry (struct RequestHandle *handle, char *pubkey, char *name)
366 * @param name the id of the ego 364 * @param name the id of the ego
367 */ 365 */
368static void 366static void
369ego_get_for_subsystem (void *cls, 367ego_get_for_subsystem(void *cls,
370 struct GNUNET_IDENTITY_Ego *ego, 368 struct GNUNET_IDENTITY_Ego *ego,
371 void **ctx, 369 void **ctx,
372 const char *name) 370 const char *name)
373{ 371{
374 struct RequestHandle *handle = cls; 372 struct RequestHandle *handle = cls;
375 struct MHD_Response *resp; 373 struct MHD_Response *resp;
@@ -379,34 +377,34 @@ ego_get_for_subsystem (void *cls,
379 char *public_key_string; 377 char *public_key_string;
380 378
381 if (NULL == ego) 379 if (NULL == ego)
382 { 380 {
383 handle->response_code = MHD_HTTP_NOT_FOUND; 381 handle->response_code = MHD_HTTP_NOT_FOUND;
384 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 382 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
385 GNUNET_SCHEDULER_add_now (&do_error, handle); 383 GNUNET_SCHEDULER_add_now(&do_error, handle);
386 return; 384 return;
387 } 385 }
388 386
389 GNUNET_IDENTITY_ego_get_public_key (ego, &public_key); 387 GNUNET_IDENTITY_ego_get_public_key(ego, &public_key);
390 public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string (&public_key); 388 public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string(&public_key);
391 389
392 // create json with subsystem identity 390 // create json with subsystem identity
393 json_root = json_object (); 391 json_root = json_object();
394 json_object_set_new (json_root, 392 json_object_set_new(json_root,
395 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 393 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
396 json_string (public_key_string)); 394 json_string(public_key_string));
397 json_object_set_new (json_root, 395 json_object_set_new(json_root,
398 GNUNET_REST_IDENTITY_PARAM_NAME, 396 GNUNET_REST_IDENTITY_PARAM_NAME,
399 json_string (name)); 397 json_string(name));
400 398
401 result_str = json_dumps (json_root, 0); 399 result_str = json_dumps(json_root, 0);
402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 400 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
403 resp = GNUNET_REST_create_response (result_str); 401 resp = GNUNET_REST_create_response(result_str);
404 402
405 json_decref (json_root); 403 json_decref(json_root);
406 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 404 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
407 GNUNET_free (result_str); 405 GNUNET_free(result_str);
408 GNUNET_free (public_key_string); 406 GNUNET_free(public_key_string);
409 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 407 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
410} 408}
411 409
412/** 410/**
@@ -417,35 +415,35 @@ ego_get_for_subsystem (void *cls,
417 * @param cls the RequestHandle 415 * @param cls the RequestHandle
418 */ 416 */
419void 417void
420ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle, 418ego_get_subsystem(struct GNUNET_REST_RequestHandle *con_handle,
421 const char *url, 419 const char *url,
422 void *cls) 420 void *cls)
423{ 421{
424 struct RequestHandle *handle = cls; 422 struct RequestHandle *handle = cls;
425 char *subsystem; 423 char *subsystem;
426 424
427 if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) 425 if (strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen(handle->url))
428 { 426 {
429 handle->emsg = GNUNET_strdup ("Missing subsystem name"); 427 handle->emsg = GNUNET_strdup("Missing subsystem name");
430 GNUNET_SCHEDULER_add_now (&do_error, handle); 428 GNUNET_SCHEDULER_add_now(&do_error, handle);
431 return; 429 return;
432 } 430 }
433 subsystem = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; 431 subsystem = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
434 //requested default identity of subsystem 432 //requested default identity of subsystem
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem); 433 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem);
436 434
437 handle->op = GNUNET_IDENTITY_get (handle->identity_handle, 435 handle->op = GNUNET_IDENTITY_get(handle->identity_handle,
438 subsystem, 436 subsystem,
439 &ego_get_for_subsystem, 437 &ego_get_for_subsystem,
440 handle); 438 handle);
441 439
442 if (NULL == handle->op) 440 if (NULL == handle->op)
443 { 441 {
444 handle->response_code = MHD_HTTP_NOT_FOUND; 442 handle->response_code = MHD_HTTP_NOT_FOUND;
445 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 443 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
446 GNUNET_SCHEDULER_add_now (&do_error, handle); 444 GNUNET_SCHEDULER_add_now(&do_error, handle);
447 return; 445 return;
448 } 446 }
449} 447}
450 448
451 449
@@ -457,9 +455,9 @@ ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
457 * @param cls the RequestHandle 455 * @param cls the RequestHandle
458 */ 456 */
459void 457void
460ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, 458ego_get_all(struct GNUNET_REST_RequestHandle *con_handle,
461 const char *url, 459 const char *url,
462 void *cls) 460 void *cls)
463{ 461{
464 struct RequestHandle *handle = cls; 462 struct RequestHandle *handle = cls;
465 struct EgoEntry *ego_entry; 463 struct EgoEntry *ego_entry;
@@ -468,30 +466,30 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
468 json_t *json_ego; 466 json_t *json_ego;
469 char *result_str; 467 char *result_str;
470 468
471 json_root = json_array (); 469 json_root = json_array();
472 //Return ego/egos 470 //Return ego/egos
473 for (ego_entry = handle->ego_head; NULL != ego_entry; 471 for (ego_entry = handle->ego_head; NULL != ego_entry;
474 ego_entry = ego_entry->next) 472 ego_entry = ego_entry->next)
475 { 473 {
476 json_ego = json_object (); 474 json_ego = json_object();
477 json_object_set_new (json_ego, 475 json_object_set_new(json_ego,
478 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 476 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
479 json_string (ego_entry->keystring)); 477 json_string(ego_entry->keystring));
480 json_object_set_new (json_ego, 478 json_object_set_new(json_ego,
481 GNUNET_REST_IDENTITY_PARAM_NAME, 479 GNUNET_REST_IDENTITY_PARAM_NAME,
482 json_string (ego_entry->identifier)); 480 json_string(ego_entry->identifier));
483 json_array_append (json_root, json_ego); 481 json_array_append(json_root, json_ego);
484 json_decref (json_ego); 482 json_decref(json_ego);
485 } 483 }
486 484
487 result_str = json_dumps (json_root, 0); 485 result_str = json_dumps(json_root, 0);
488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 486 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
489 resp = GNUNET_REST_create_response (result_str); 487 resp = GNUNET_REST_create_response(result_str);
490 488
491 json_decref (json_root); 489 json_decref(json_root);
492 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 490 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
493 GNUNET_free (result_str); 491 GNUNET_free(result_str);
494 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 492 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
495} 493}
496 494
497 495
@@ -502,28 +500,28 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
502 * @param ego_entry the struct EgoEntry for the response 500 * @param ego_entry the struct EgoEntry for the response
503 */ 501 */
504void 502void
505ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) 503ego_get_response(struct RequestHandle *handle, struct EgoEntry *ego_entry)
506{ 504{
507 struct MHD_Response *resp; 505 struct MHD_Response *resp;
508 json_t *json_ego; 506 json_t *json_ego;
509 char *result_str; 507 char *result_str;
510 508
511 json_ego = json_object (); 509 json_ego = json_object();
512 json_object_set_new (json_ego, 510 json_object_set_new(json_ego,
513 GNUNET_REST_IDENTITY_PARAM_PUBKEY, 511 GNUNET_REST_IDENTITY_PARAM_PUBKEY,
514 json_string (ego_entry->keystring)); 512 json_string(ego_entry->keystring));
515 json_object_set_new (json_ego, 513 json_object_set_new(json_ego,
516 GNUNET_REST_IDENTITY_PARAM_NAME, 514 GNUNET_REST_IDENTITY_PARAM_NAME,
517 json_string (ego_entry->identifier)); 515 json_string(ego_entry->identifier));
518 516
519 result_str = json_dumps (json_ego, 0); 517 result_str = json_dumps(json_ego, 0);
520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 518 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
521 resp = GNUNET_REST_create_response (result_str); 519 resp = GNUNET_REST_create_response(result_str);
522 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 520 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
523 521
524 json_decref (json_ego); 522 json_decref(json_ego);
525 GNUNET_free (result_str); 523 GNUNET_free(result_str);
526 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 524 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
527} 525}
528 526
529 527
@@ -535,9 +533,9 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
535 * @param cls the RequestHandle 533 * @param cls the RequestHandle
536 */ 534 */
537void 535void
538ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle, 536ego_get_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
539 const char *url, 537 const char *url,
540 void *cls) 538 void *cls)
541{ 539{
542 struct RequestHandle *handle = cls; 540 struct RequestHandle *handle = cls;
543 struct EgoEntry *ego_entry; 541 struct EgoEntry *ego_entry;
@@ -545,25 +543,25 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
545 543
546 keystring = NULL; 544 keystring = NULL;
547 545
548 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) 546 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url))
549 { 547 {
550 handle->response_code = MHD_HTTP_NOT_FOUND; 548 handle->response_code = MHD_HTTP_NOT_FOUND;
551 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); 549 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
552 GNUNET_SCHEDULER_add_now (&do_error, handle); 550 GNUNET_SCHEDULER_add_now(&do_error, handle);
553 return; 551 return;
554 } 552 }
555 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 553 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
556 ego_entry = get_egoentry (handle, keystring, NULL); 554 ego_entry = get_egoentry(handle, keystring, NULL);
557 555
558 if (NULL == ego_entry) 556 if (NULL == ego_entry)
559 { 557 {
560 handle->response_code = MHD_HTTP_NOT_FOUND; 558 handle->response_code = MHD_HTTP_NOT_FOUND;
561 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 559 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
562 GNUNET_SCHEDULER_add_now (&do_error, handle); 560 GNUNET_SCHEDULER_add_now(&do_error, handle);
563 return; 561 return;
564 } 562 }
565 563
566 ego_get_response (handle, ego_entry); 564 ego_get_response(handle, ego_entry);
567} 565}
568 566
569/** 567/**
@@ -574,9 +572,9 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
574 * @param cls the RequestHandle 572 * @param cls the RequestHandle
575 */ 573 */
576void 574void
577ego_get_name (struct GNUNET_REST_RequestHandle *con_handle, 575ego_get_name(struct GNUNET_REST_RequestHandle *con_handle,
578 const char *url, 576 const char *url,
579 void *cls) 577 void *cls)
580{ 578{
581 struct RequestHandle *handle = cls; 579 struct RequestHandle *handle = cls;
582 struct EgoEntry *ego_entry; 580 struct EgoEntry *ego_entry;
@@ -584,25 +582,25 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
584 582
585 egoname = NULL; 583 egoname = NULL;
586 584
587 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) 585 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url))
588 { 586 {
589 handle->response_code = MHD_HTTP_NOT_FOUND; 587 handle->response_code = MHD_HTTP_NOT_FOUND;
590 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); 588 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
591 GNUNET_SCHEDULER_add_now (&do_error, handle); 589 GNUNET_SCHEDULER_add_now(&do_error, handle);
592 return; 590 return;
593 } 591 }
594 egoname = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 592 egoname = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
595 ego_entry = get_egoentry (handle, NULL, egoname); 593 ego_entry = get_egoentry(handle, NULL, egoname);
596 594
597 if (NULL == ego_entry) 595 if (NULL == ego_entry)
598 { 596 {
599 handle->response_code = MHD_HTTP_NOT_FOUND; 597 handle->response_code = MHD_HTTP_NOT_FOUND;
600 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 598 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
601 GNUNET_SCHEDULER_add_now (&do_error, handle); 599 GNUNET_SCHEDULER_add_now(&do_error, handle);
602 return; 600 return;
603 } 601 }
604 602
605 ego_get_response (handle, ego_entry); 603 ego_get_response(handle, ego_entry);
606} 604}
607 605
608 606
@@ -613,25 +611,25 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
613 * @param emsg error message 611 * @param emsg error message
614 */ 612 */
615static void 613static void
616do_finished (void *cls, const char *emsg) 614do_finished(void *cls, const char *emsg)
617{ 615{
618 struct RequestHandle *handle = cls; 616 struct RequestHandle *handle = cls;
619 struct MHD_Response *resp; 617 struct MHD_Response *resp;
620 618
621 handle->op = NULL; 619 handle->op = NULL;
622 if (NULL != emsg) 620 if (NULL != emsg)
623 { 621 {
624 handle->emsg = GNUNET_strdup (emsg); 622 handle->emsg = GNUNET_strdup(emsg);
625 GNUNET_SCHEDULER_add_now (&do_error, handle); 623 GNUNET_SCHEDULER_add_now(&do_error, handle);
626 return; 624 return;
627 } 625 }
628 if (0 == handle->response_code) 626 if (0 == handle->response_code)
629 { 627 {
630 handle->response_code = MHD_HTTP_NO_CONTENT; 628 handle->response_code = MHD_HTTP_NO_CONTENT;
631 } 629 }
632 resp = GNUNET_REST_create_response (NULL); 630 resp = GNUNET_REST_create_response(NULL);
633 handle->proc (handle->proc_cls, resp, handle->response_code); 631 handle->proc(handle->proc_cls, resp, handle->response_code);
634 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 632 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
635} 633}
636 634
637 635
@@ -643,14 +641,14 @@ do_finished (void *cls, const char *emsg)
643 * @param emsg error message 641 * @param emsg error message
644 */ 642 */
645static void 643static void
646do_finished_create (void *cls, 644do_finished_create(void *cls,
647 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 645 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
648 const char *emsg) 646 const char *emsg)
649{ 647{
650 struct RequestHandle *handle = cls; 648 struct RequestHandle *handle = cls;
651 649
652 (void) pk; 650 (void)pk;
653 do_finished (handle, emsg); 651 do_finished(handle, emsg);
654} 652}
655 653
656 654
@@ -661,7 +659,7 @@ do_finished_create (void *cls,
661 * @param ego_entry the struct EgoEntry we want to edit 659 * @param ego_entry the struct EgoEntry we want to edit
662 */ 660 */
663void 661void
664ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) 662ego_edit(struct RequestHandle *handle, struct EgoEntry *ego_entry)
665{ 663{
666 struct EgoEntry *ego_entry_tmp; 664 struct EgoEntry *ego_entry_tmp;
667 struct MHD_Response *resp; 665 struct MHD_Response *resp;
@@ -673,79 +671,78 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry)
673 671
674 //if no data 672 //if no data
675 if (0 >= handle->data_size) 673 if (0 >= handle->data_size)
676 { 674 {
677 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 675 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
678 GNUNET_SCHEDULER_add_now (&do_error, handle); 676 GNUNET_SCHEDULER_add_now(&do_error, handle);
679 return; 677 return;
680 } 678 }
681 //if not json 679 //if not json
682 term_data[handle->data_size] = '\0'; 680 term_data[handle->data_size] = '\0';
683 GNUNET_memcpy (term_data, handle->data, handle->data_size); 681 GNUNET_memcpy(term_data, handle->data, handle->data_size);
684 data_js = json_loads (term_data, JSON_DECODE_ANY, &err); 682 data_js = json_loads(term_data, JSON_DECODE_ANY, &err);
685 683
686 if (NULL == data_js) 684 if (NULL == data_js)
687 { 685 {
688 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 686 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
689 GNUNET_SCHEDULER_add_now (&do_error, handle); 687 GNUNET_SCHEDULER_add_now(&do_error, handle);
690 return; 688 return;
691 } 689 }
692 690
693 newname = NULL; 691 newname = NULL;
694 //NEW NAME 692 //NEW NAME
695 json_state = 0; 693 json_state = 0;
696 json_state = json_unpack (data_js, 694 json_state = json_unpack(data_js,
697 "{s:s!}", 695 "{s:s!}",
698 GNUNET_REST_IDENTITY_PARAM_NEWNAME, 696 GNUNET_REST_IDENTITY_PARAM_NEWNAME,
699 &newname); 697 &newname);
700 //Change name with pubkey or name identifier 698 //Change name with pubkey or name identifier
701 if (0 != json_state) 699 if (0 != json_state)
702 { 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 }
709 706
710 if (NULL == newname) 707 if (NULL == newname)
711 { 708 {
712 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 709 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
713 GNUNET_SCHEDULER_add_now (&do_error, handle); 710 GNUNET_SCHEDULER_add_now(&do_error, handle);
714 json_decref (data_js); 711 json_decref(data_js);
715 return; 712 return;
716 } 713 }
717 714
718 if (0 >= strlen (newname)) 715 if (0 >= strlen(newname))
719 { 716 {
720 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 717 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
721 GNUNET_SCHEDULER_add_now (&do_error, handle); 718 GNUNET_SCHEDULER_add_now(&do_error, handle);
722 json_decref (data_js); 719 json_decref(data_js);
723 return; 720 return;
724 } 721 }
725 722
726 ego_entry_tmp = get_egoentry (handle, NULL, newname); 723 ego_entry_tmp = get_egoentry(handle, NULL, newname);
727 if (NULL != ego_entry_tmp) 724 if (NULL != ego_entry_tmp)
728 { 725 {
729 //Ego with same name not allowed (even if its the ego we change) 726 //Ego with same name not allowed (even if its the ego we change)
730 resp = GNUNET_REST_create_response (NULL); 727 resp = GNUNET_REST_create_response(NULL);
731 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); 728 handle->proc(handle->proc_cls, resp, MHD_HTTP_CONFLICT);
732 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 729 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
733 json_decref (data_js); 730 json_decref(data_js);
734 return; 731 return;
735 } 732 }
736 handle->op = GNUNET_IDENTITY_rename (handle->identity_handle, 733 handle->op = GNUNET_IDENTITY_rename(handle->identity_handle,
737 ego_entry->identifier, 734 ego_entry->identifier,
738 newname, 735 newname,
739 &do_finished, 736 &do_finished,
740 handle); 737 handle);
741 if (NULL == handle->op) 738 if (NULL == handle->op)
742 { 739 {
743 handle->emsg = GNUNET_strdup ("Rename failed"); 740 handle->emsg = GNUNET_strdup("Rename failed");
744 GNUNET_SCHEDULER_add_now (&do_error, handle); 741 GNUNET_SCHEDULER_add_now(&do_error, handle);
745 json_decref (data_js); 742 json_decref(data_js);
746 return; 743 return;
747 } 744 }
748 json_decref (data_js); 745 json_decref(data_js);
749 return; 746 return;
750} 747}
751 748
@@ -758,9 +755,9 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry)
758 * @param cls the RequestHandle 755 * @param cls the RequestHandle
759 */ 756 */
760void 757void
761ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle, 758ego_edit_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
762 const char *url, 759 const char *url,
763 void *cls) 760 void *cls)
764{ 761{
765 struct RequestHandle *handle = cls; 762 struct RequestHandle *handle = cls;
766 struct EgoEntry *ego_entry; 763 struct EgoEntry *ego_entry;
@@ -768,25 +765,25 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
768 765
769 keystring = NULL; 766 keystring = NULL;
770 767
771 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) 768 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url))
772 { 769 {
773 handle->response_code = MHD_HTTP_NOT_FOUND; 770 handle->response_code = MHD_HTTP_NOT_FOUND;
774 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); 771 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
775 GNUNET_SCHEDULER_add_now (&do_error, handle); 772 GNUNET_SCHEDULER_add_now(&do_error, handle);
776 return; 773 return;
777 } 774 }
778 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 775 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
779 ego_entry = get_egoentry (handle, keystring, NULL); 776 ego_entry = get_egoentry(handle, keystring, NULL);
780 777
781 if (NULL == ego_entry) 778 if (NULL == ego_entry)
782 { 779 {
783 handle->response_code = MHD_HTTP_NOT_FOUND; 780 handle->response_code = MHD_HTTP_NOT_FOUND;
784 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 781 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
785 GNUNET_SCHEDULER_add_now (&do_error, handle); 782 GNUNET_SCHEDULER_add_now(&do_error, handle);
786 return; 783 return;
787 } 784 }
788 785
789 ego_edit (handle, ego_entry); 786 ego_edit(handle, ego_entry);
790} 787}
791 788
792/** 789/**
@@ -797,9 +794,9 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
797 * @param cls the RequestHandle 794 * @param cls the RequestHandle
798 */ 795 */
799void 796void
800ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle, 797ego_edit_name(struct GNUNET_REST_RequestHandle *con_handle,
801 const char *url, 798 const char *url,
802 void *cls) 799 void *cls)
803{ 800{
804 struct RequestHandle *handle = cls; 801 struct RequestHandle *handle = cls;
805 struct EgoEntry *ego_entry; 802 struct EgoEntry *ego_entry;
@@ -807,25 +804,25 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
807 804
808 name = NULL; 805 name = NULL;
809 806
810 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) 807 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url))
811 { 808 {
812 handle->response_code = MHD_HTTP_NOT_FOUND; 809 handle->response_code = MHD_HTTP_NOT_FOUND;
813 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); 810 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
814 GNUNET_SCHEDULER_add_now (&do_error, handle); 811 GNUNET_SCHEDULER_add_now(&do_error, handle);
815 return; 812 return;
816 } 813 }
817 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 814 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
818 ego_entry = get_egoentry (handle, NULL, name); 815 ego_entry = get_egoentry(handle, NULL, name);
819 816
820 if (NULL == ego_entry) 817 if (NULL == ego_entry)
821 { 818 {
822 handle->response_code = MHD_HTTP_NOT_FOUND; 819 handle->response_code = MHD_HTTP_NOT_FOUND;
823 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 820 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
824 GNUNET_SCHEDULER_add_now (&do_error, handle); 821 GNUNET_SCHEDULER_add_now(&do_error, handle);
825 return; 822 return;
826 } 823 }
827 824
828 ego_edit (handle, ego_entry); 825 ego_edit(handle, ego_entry);
829} 826}
830 827
831/** 828/**
@@ -836,9 +833,9 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
836 * @param cls the RequestHandle 833 * @param cls the RequestHandle
837 */ 834 */
838void 835void
839ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, 836ego_edit_subsystem(struct GNUNET_REST_RequestHandle *con_handle,
840 const char *url, 837 const char *url,
841 void *cls) 838 void *cls)
842{ 839{
843 struct RequestHandle *handle = cls; 840 struct RequestHandle *handle = cls;
844 struct EgoEntry *ego_entry; 841 struct EgoEntry *ego_entry;
@@ -851,88 +848,88 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
851 848
852 name = NULL; 849 name = NULL;
853 850
854 if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) 851 if (strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen(handle->url))
855 { 852 {
856 handle->response_code = MHD_HTTP_NOT_FOUND; 853 handle->response_code = MHD_HTTP_NOT_FOUND;
857 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); 854 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
858 GNUNET_SCHEDULER_add_now (&do_error, handle); 855 GNUNET_SCHEDULER_add_now(&do_error, handle);
859 return; 856 return;
860 } 857 }
861 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; 858 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
862 ego_entry = get_egoentry (handle, NULL, name); 859 ego_entry = get_egoentry(handle, NULL, name);
863 860
864 if (NULL == ego_entry) 861 if (NULL == ego_entry)
865 { 862 {
866 handle->response_code = MHD_HTTP_NOT_FOUND; 863 handle->response_code = MHD_HTTP_NOT_FOUND;
867 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 864 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
868 GNUNET_SCHEDULER_add_now (&do_error, handle); 865 GNUNET_SCHEDULER_add_now(&do_error, handle);
869 return; 866 return;
870 } 867 }
871 868
872 //if no data 869 //if no data
873 if (0 >= handle->data_size) 870 if (0 >= handle->data_size)
874 { 871 {
875 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 872 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
876 GNUNET_SCHEDULER_add_now (&do_error, handle); 873 GNUNET_SCHEDULER_add_now(&do_error, handle);
877 return; 874 return;
878 } 875 }
879 //if not json 876 //if not json
880 term_data[handle->data_size] = '\0'; 877 term_data[handle->data_size] = '\0';
881 GNUNET_memcpy (term_data, handle->data, handle->data_size); 878 GNUNET_memcpy(term_data, handle->data, handle->data_size);
882 data_js = json_loads (term_data, JSON_DECODE_ANY, &err); 879 data_js = json_loads(term_data, JSON_DECODE_ANY, &err);
883 880
884 if (NULL == data_js) 881 if (NULL == data_js)
885 { 882 {
886 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 883 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
887 GNUNET_SCHEDULER_add_now (&do_error, handle); 884 GNUNET_SCHEDULER_add_now(&do_error, handle);
888 return; 885 return;
889 } 886 }
890 887
891 newsubsys = NULL; 888 newsubsys = NULL;
892 //SUBSYSTEM 889 //SUBSYSTEM
893 json_state = 0; 890 json_state = 0;
894 json_state = json_unpack (data_js, 891 json_state = json_unpack(data_js,
895 "{s:s!}", 892 "{s:s!}",
896 GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM, 893 GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM,
897 &newsubsys); 894 &newsubsys);
898 //Change subsystem with pubkey or name identifier 895 //Change subsystem with pubkey or name identifier
899 if (0 != json_state) 896 if (0 != json_state)
900 { 897 {
901 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 898 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
902 GNUNET_SCHEDULER_add_now (&do_error, handle); 899 GNUNET_SCHEDULER_add_now(&do_error, handle);
903 json_decref (data_js); 900 json_decref(data_js);
904 return; 901 return;
905 } 902 }
906 903
907 if (NULL == newsubsys) 904 if (NULL == newsubsys)
908 { 905 {
909 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 906 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
910 GNUNET_SCHEDULER_add_now (&do_error, handle); 907 GNUNET_SCHEDULER_add_now(&do_error, handle);
911 json_decref (data_js); 908 json_decref(data_js);
912 return; 909 return;
913 } 910 }
914 911
915 if (0 >= strlen (newsubsys)) 912 if (0 >= strlen(newsubsys))
916 { 913 {
917 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 914 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
918 GNUNET_SCHEDULER_add_now (&do_error, handle); 915 GNUNET_SCHEDULER_add_now(&do_error, handle);
919 json_decref (data_js); 916 json_decref(data_js);
920 return; 917 return;
921 } 918 }
922 919
923 handle->response_code = MHD_HTTP_NO_CONTENT; 920 handle->response_code = MHD_HTTP_NO_CONTENT;
924 handle->op = GNUNET_IDENTITY_set (handle->identity_handle, 921 handle->op = GNUNET_IDENTITY_set(handle->identity_handle,
925 newsubsys, 922 newsubsys,
926 ego_entry->ego, 923 ego_entry->ego,
927 &do_finished, 924 &do_finished,
928 handle); 925 handle);
929 if (NULL == handle->op) 926 if (NULL == handle->op)
930 { 927 {
931 handle->emsg = GNUNET_strdup ("Setting subsystem failed"); 928 handle->emsg = GNUNET_strdup("Setting subsystem failed");
932 GNUNET_SCHEDULER_add_now (&do_error, handle); 929 GNUNET_SCHEDULER_add_now(&do_error, handle);
933 return; 930 return;
934 } 931 }
935 json_decref (data_js); 932 json_decref(data_js);
936 return; 933 return;
937} 934}
938 935
@@ -944,9 +941,9 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
944 * @param cls the RequestHandle 941 * @param cls the RequestHandle
945 */ 942 */
946void 943void
947ego_create (struct GNUNET_REST_RequestHandle *con_handle, 944ego_create(struct GNUNET_REST_RequestHandle *con_handle,
948 const char *url, 945 const char *url,
949 void *cls) 946 void *cls)
950{ 947{
951 struct RequestHandle *handle = cls; 948 struct RequestHandle *handle = cls;
952 struct EgoEntry *ego_entry; 949 struct EgoEntry *ego_entry;
@@ -957,73 +954,73 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
957 int json_unpack_state; 954 int json_unpack_state;
958 char term_data[handle->data_size + 1]; 955 char term_data[handle->data_size + 1];
959 956
960 if (strlen (GNUNET_REST_API_NS_IDENTITY) != strlen (handle->url)) 957 if (strlen(GNUNET_REST_API_NS_IDENTITY) != strlen(handle->url))
961 { 958 {
962 GNUNET_SCHEDULER_add_now (&do_error, handle); 959 GNUNET_SCHEDULER_add_now(&do_error, handle);
963 return; 960 return;
964 } 961 }
965 962
966 if (0 >= handle->data_size) 963 if (0 >= handle->data_size)
967 { 964 {
968 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 965 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
969 GNUNET_SCHEDULER_add_now (&do_error, handle); 966 GNUNET_SCHEDULER_add_now(&do_error, handle);
970 return; 967 return;
971 } 968 }
972 term_data[handle->data_size] = '\0'; 969 term_data[handle->data_size] = '\0';
973 GNUNET_memcpy (term_data, handle->data, handle->data_size); 970 GNUNET_memcpy(term_data, handle->data, handle->data_size);
974 data_js = json_loads (term_data, JSON_DECODE_ANY, &err); 971 data_js = json_loads(term_data, JSON_DECODE_ANY, &err);
975 if (NULL == data_js) 972 if (NULL == data_js)
976 { 973 {
977 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); 974 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
978 GNUNET_SCHEDULER_add_now (&do_error, handle); 975 GNUNET_SCHEDULER_add_now(&do_error, handle);
979 json_decref (data_js); 976 json_decref(data_js);
980 return; 977 return;
981 } 978 }
982 json_unpack_state = 0; 979 json_unpack_state = 0;
983 json_unpack_state = 980 json_unpack_state =
984 json_unpack (data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname); 981 json_unpack(data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname);
985 if (0 != json_unpack_state) 982 if (0 != json_unpack_state)
986 { 983 {
987 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 984 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
988 GNUNET_SCHEDULER_add_now (&do_error, handle); 985 GNUNET_SCHEDULER_add_now(&do_error, handle);
989 json_decref (data_js); 986 json_decref(data_js);
990 return; 987 return;
991 } 988 }
992 989
993 if (NULL == egoname) 990 if (NULL == egoname)
994 { 991 {
995 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 992 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
996 GNUNET_SCHEDULER_add_now (&do_error, handle); 993 GNUNET_SCHEDULER_add_now(&do_error, handle);
997 json_decref (data_js); 994 json_decref(data_js);
998 return; 995 return;
999 } 996 }
1000 if (0 >= strlen (egoname)) 997 if (0 >= strlen(egoname))
1001 { 998 {
1002 json_decref (data_js); 999 json_decref(data_js);
1003 handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); 1000 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
1004 GNUNET_SCHEDULER_add_now (&do_error, handle); 1001 GNUNET_SCHEDULER_add_now(&do_error, handle);
1005 return; 1002 return;
1006 } 1003 }
1007 GNUNET_STRINGS_utf8_tolower (egoname, egoname); 1004 GNUNET_STRINGS_utf8_tolower(egoname, egoname);
1008 for (ego_entry = handle->ego_head; NULL != ego_entry; 1005 for (ego_entry = handle->ego_head; NULL != ego_entry;
1009 ego_entry = ego_entry->next) 1006 ego_entry = ego_entry->next)
1010 {
1011 if (0 == strcasecmp (egoname, ego_entry->identifier))
1012 { 1007 {
1013 resp = GNUNET_REST_create_response (NULL); 1008 if (0 == strcasecmp(egoname, ego_entry->identifier))
1014 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); 1009 {
1015 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 1010 resp = GNUNET_REST_create_response(NULL);
1016 json_decref (data_js); 1011 handle->proc(handle->proc_cls, resp, MHD_HTTP_CONFLICT);
1017 return; 1012 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
1013 json_decref(data_js);
1014 return;
1015 }
1018 } 1016 }
1019 } 1017 handle->name = GNUNET_strdup(egoname);
1020 handle->name = GNUNET_strdup (egoname); 1018 json_decref(data_js);
1021 json_decref (data_js);
1022 handle->response_code = MHD_HTTP_CREATED; 1019 handle->response_code = MHD_HTTP_CREATED;
1023 handle->op = GNUNET_IDENTITY_create (handle->identity_handle, 1020 handle->op = GNUNET_IDENTITY_create(handle->identity_handle,
1024 handle->name, 1021 handle->name,
1025 &do_finished_create, 1022 &do_finished_create,
1026 handle); 1023 handle);
1027} 1024}
1028 1025
1029/** 1026/**
@@ -1034,9 +1031,9 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
1034 * @param cls the RequestHandle 1031 * @param cls the RequestHandle
1035 */ 1032 */
1036void 1033void
1037ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle, 1034ego_delete_pubkey(struct GNUNET_REST_RequestHandle *con_handle,
1038 const char *url, 1035 const char *url,
1039 void *cls) 1036 void *cls)
1040{ 1037{
1041 struct RequestHandle *handle = cls; 1038 struct RequestHandle *handle = cls;
1042 struct EgoEntry *ego_entry; 1039 struct EgoEntry *ego_entry;
@@ -1044,29 +1041,29 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
1044 1041
1045 keystring = NULL; 1042 keystring = NULL;
1046 1043
1047 if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) 1044 if (strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen(handle->url))
1048 { 1045 {
1049 handle->response_code = MHD_HTTP_NOT_FOUND; 1046 handle->response_code = MHD_HTTP_NOT_FOUND;
1050 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); 1047 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
1051 GNUNET_SCHEDULER_add_now (&do_error, handle); 1048 GNUNET_SCHEDULER_add_now(&do_error, handle);
1052 return; 1049 return;
1053 } 1050 }
1054 keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; 1051 keystring = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1];
1055 ego_entry = get_egoentry (handle, keystring, NULL); 1052 ego_entry = get_egoentry(handle, keystring, NULL);
1056 1053
1057 if (NULL == ego_entry) 1054 if (NULL == ego_entry)
1058 { 1055 {
1059 handle->response_code = MHD_HTTP_NOT_FOUND; 1056 handle->response_code = MHD_HTTP_NOT_FOUND;
1060 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 1057 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
1061 GNUNET_SCHEDULER_add_now (&do_error, handle); 1058 GNUNET_SCHEDULER_add_now(&do_error, handle);
1062 return; 1059 return;
1063 } 1060 }
1064 1061
1065 handle->response_code = MHD_HTTP_NO_CONTENT; 1062 handle->response_code = MHD_HTTP_NO_CONTENT;
1066 handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, 1063 handle->op = GNUNET_IDENTITY_delete(handle->identity_handle,
1067 ego_entry->identifier, 1064 ego_entry->identifier,
1068 &do_finished, 1065 &do_finished,
1069 handle); 1066 handle);
1070} 1067}
1071 1068
1072 1069
@@ -1078,9 +1075,9 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
1078 * @param cls the RequestHandle 1075 * @param cls the RequestHandle
1079 */ 1076 */
1080void 1077void
1081ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle, 1078ego_delete_name(struct GNUNET_REST_RequestHandle *con_handle,
1082 const char *url, 1079 const char *url,
1083 void *cls) 1080 void *cls)
1084{ 1081{
1085 struct RequestHandle *handle = cls; 1082 struct RequestHandle *handle = cls;
1086 struct EgoEntry *ego_entry; 1083 struct EgoEntry *ego_entry;
@@ -1088,29 +1085,29 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
1088 1085
1089 name = NULL; 1086 name = NULL;
1090 1087
1091 if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) 1088 if (strlen(GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen(handle->url))
1092 { 1089 {
1093 handle->response_code = MHD_HTTP_NOT_FOUND; 1090 handle->response_code = MHD_HTTP_NOT_FOUND;
1094 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); 1091 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
1095 GNUNET_SCHEDULER_add_now (&do_error, handle); 1092 GNUNET_SCHEDULER_add_now(&do_error, handle);
1096 return; 1093 return;
1097 } 1094 }
1098 name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; 1095 name = &handle->url[strlen(GNUNET_REST_API_NS_IDENTITY_NAME) + 1];
1099 ego_entry = get_egoentry (handle, NULL, name); 1096 ego_entry = get_egoentry(handle, NULL, name);
1100 1097
1101 if (NULL == ego_entry) 1098 if (NULL == ego_entry)
1102 { 1099 {
1103 handle->response_code = MHD_HTTP_NOT_FOUND; 1100 handle->response_code = MHD_HTTP_NOT_FOUND;
1104 handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); 1101 handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
1105 GNUNET_SCHEDULER_add_now (&do_error, handle); 1102 GNUNET_SCHEDULER_add_now(&do_error, handle);
1106 return; 1103 return;
1107 } 1104 }
1108 1105
1109 handle->response_code = MHD_HTTP_NO_CONTENT; 1106 handle->response_code = MHD_HTTP_NO_CONTENT;
1110 handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, 1107 handle->op = GNUNET_IDENTITY_delete(handle->identity_handle,
1111 ego_entry->identifier, 1108 ego_entry->identifier,
1112 &do_finished, 1109 &do_finished,
1113 handle); 1110 handle);
1114} 1111}
1115 1112
1116 1113
@@ -1122,18 +1119,18 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
1122 * @param cls the RequestHandle 1119 * @param cls the RequestHandle
1123 */ 1120 */
1124static void 1121static void
1125options_cont (struct GNUNET_REST_RequestHandle *con_handle, 1122options_cont(struct GNUNET_REST_RequestHandle *con_handle,
1126 const char *url, 1123 const char *url,
1127 void *cls) 1124 void *cls)
1128{ 1125{
1129 struct MHD_Response *resp; 1126 struct MHD_Response *resp;
1130 struct RequestHandle *handle = cls; 1127 struct RequestHandle *handle = cls;
1131 1128
1132 //For now, independent of path return all options 1129 //For now, independent of path return all options
1133 resp = GNUNET_REST_create_response (NULL); 1130 resp = GNUNET_REST_create_response(NULL);
1134 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); 1131 MHD_add_response_header(resp, "Access-Control-Allow-Methods", allow_methods);
1135 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 1132 handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
1136 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 1133 GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
1137 return; 1134 return;
1138} 1135}
1139 1136
@@ -1143,39 +1140,39 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
1143 * @param handle the request handle 1140 * @param handle the request handle
1144 */ 1141 */
1145static void 1142static void
1146init_cont (struct RequestHandle *handle) 1143init_cont(struct RequestHandle *handle)
1147{ 1144{
1148 struct GNUNET_REST_RequestHandlerError err; 1145 struct GNUNET_REST_RequestHandlerError err;
1149 static const struct GNUNET_REST_RequestHandler handlers[] = 1146 static const struct GNUNET_REST_RequestHandler handlers[] =
1150 {{MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ALL, &ego_get_all}, 1147 { { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ALL, &ego_get_all },
1151 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey}, 1148 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey },
1152 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name}, 1149 { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name },
1153 {MHD_HTTP_METHOD_GET, 1150 { MHD_HTTP_METHOD_GET,
1154 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, 1151 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
1155 &ego_get_subsystem}, 1152 &ego_get_subsystem },
1156 {MHD_HTTP_METHOD_PUT, 1153 { MHD_HTTP_METHOD_PUT,
1157 GNUNET_REST_API_NS_IDENTITY_PUBKEY, 1154 GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1158 &ego_edit_pubkey}, 1155 &ego_edit_pubkey },
1159 {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name}, 1156 { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name },
1160 {MHD_HTTP_METHOD_PUT, 1157 { MHD_HTTP_METHOD_PUT,
1161 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, 1158 GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
1162 &ego_edit_subsystem}, 1159 &ego_edit_subsystem },
1163 {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create}, 1160 { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create },
1164 {MHD_HTTP_METHOD_DELETE, 1161 { MHD_HTTP_METHOD_DELETE,
1165 GNUNET_REST_API_NS_IDENTITY_PUBKEY, 1162 GNUNET_REST_API_NS_IDENTITY_PUBKEY,
1166 &ego_delete_pubkey}, 1163 &ego_delete_pubkey },
1167 {MHD_HTTP_METHOD_DELETE, 1164 { MHD_HTTP_METHOD_DELETE,
1168 GNUNET_REST_API_NS_IDENTITY_NAME, 1165 GNUNET_REST_API_NS_IDENTITY_NAME,
1169 &ego_delete_name}, 1166 &ego_delete_name },
1170 {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont}, 1167 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont },
1171 GNUNET_REST_HANDLER_END}; 1168 GNUNET_REST_HANDLER_END };
1172 1169
1173 if (GNUNET_NO == 1170 if (GNUNET_NO ==
1174 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) 1171 GNUNET_REST_handle_request(handle->rest_handle, handlers, &err, handle))
1175 { 1172 {
1176 handle->response_code = err.error_code; 1173 handle->response_code = err.error_code;
1177 GNUNET_SCHEDULER_add_now (&do_error, handle); 1174 GNUNET_SCHEDULER_add_now(&do_error, handle);
1178 } 1175 }
1179} 1176}
1180 1177
1181/** 1178/**
@@ -1212,32 +1209,32 @@ init_cont (struct RequestHandle *handle)
1212 * must thus no longer be used 1209 * must thus no longer be used
1213 */ 1210 */
1214static void 1211static void
1215init_egos (void *cls, 1212init_egos(void *cls,
1216 struct GNUNET_IDENTITY_Ego *ego, 1213 struct GNUNET_IDENTITY_Ego *ego,
1217 void **ctx, 1214 void **ctx,
1218 const char *identifier) 1215 const char *identifier)
1219{ 1216{
1220 struct RequestHandle *handle = cls; 1217 struct RequestHandle *handle = cls;
1221 struct EgoEntry *ego_entry; 1218 struct EgoEntry *ego_entry;
1222 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 1219 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
1223 1220
1224 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) 1221 if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1225 { 1222 {
1226 handle->state = ID_REST_STATE_POST_INIT; 1223 handle->state = ID_REST_STATE_POST_INIT;
1227 init_cont (handle); 1224 init_cont(handle);
1228 return; 1225 return;
1229 } 1226 }
1230 if (ID_REST_STATE_INIT == handle->state) 1227 if (ID_REST_STATE_INIT == handle->state)
1231 { 1228 {
1232 ego_entry = GNUNET_new (struct EgoEntry); 1229 ego_entry = GNUNET_new(struct EgoEntry);
1233 GNUNET_IDENTITY_ego_get_public_key (ego, &pk); 1230 GNUNET_IDENTITY_ego_get_public_key(ego, &pk);
1234 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); 1231 ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string(&pk);
1235 ego_entry->ego = ego; 1232 ego_entry->ego = ego;
1236 GNUNET_asprintf (&ego_entry->identifier, "%s", identifier); 1233 GNUNET_asprintf(&ego_entry->identifier, "%s", identifier);
1237 GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head, 1234 GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head,
1238 handle->ego_tail, 1235 handle->ego_tail,
1239 ego_entry); 1236 ego_entry);
1240 } 1237 }
1241} 1238}
1242 1239
1243/** 1240/**
@@ -1252,11 +1249,11 @@ init_egos (void *cls,
1252 * @return GNUNET_OK if request accepted 1249 * @return GNUNET_OK if request accepted
1253 */ 1250 */
1254static void 1251static void
1255rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, 1252rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
1256 GNUNET_REST_ResultProcessor proc, 1253 GNUNET_REST_ResultProcessor proc,
1257 void *proc_cls) 1254 void *proc_cls)
1258{ 1255{
1259 struct RequestHandle *handle = GNUNET_new (struct RequestHandle); 1256 struct RequestHandle *handle = GNUNET_new(struct RequestHandle);
1260 1257
1261 handle->response_code = 0; 1258 handle->response_code = 0;
1262 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1259 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1266,17 +1263,17 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1266 handle->data = rest_handle->data; 1263 handle->data = rest_handle->data;
1267 handle->data_size = rest_handle->data_size; 1264 handle->data_size = rest_handle->data_size;
1268 1265
1269 handle->url = GNUNET_strdup (rest_handle->url); 1266 handle->url = GNUNET_strdup(rest_handle->url);
1270 if (handle->url[strlen (handle->url) - 1] == '/') 1267 if (handle->url[strlen(handle->url) - 1] == '/')
1271 handle->url[strlen (handle->url) - 1] = '\0'; 1268 handle->url[strlen(handle->url) - 1] = '\0';
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); 1269 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1273 1270
1274 handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &init_egos, handle); 1271 handle->identity_handle = GNUNET_IDENTITY_connect(cfg, &init_egos, handle);
1275 1272
1276 handle->timeout_task = 1273 handle->timeout_task =
1277 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); 1274 GNUNET_SCHEDULER_add_delayed(handle->timeout, &do_error, handle);
1278 1275
1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); 1276 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1280} 1277}
1281 1278
1282/** 1279/**
@@ -1286,7 +1283,7 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1286 * @return NULL on error, otherwise the plugin context 1283 * @return NULL on error, otherwise the plugin context
1287 */ 1284 */
1288void * 1285void *
1289libgnunet_plugin_rest_identity_init (void *cls) 1286libgnunet_plugin_rest_identity_init(void *cls)
1290{ 1287{
1291 static struct Plugin plugin; 1288 static struct Plugin plugin;
1292 struct GNUNET_REST_Plugin *api; 1289 struct GNUNET_REST_Plugin *api;
@@ -1294,21 +1291,21 @@ libgnunet_plugin_rest_identity_init (void *cls)
1294 cfg = cls; 1291 cfg = cls;
1295 if (NULL != plugin.cfg) 1292 if (NULL != plugin.cfg)
1296 return NULL; /* can only initialize once! */ 1293 return NULL; /* can only initialize once! */
1297 memset (&plugin, 0, sizeof (struct Plugin)); 1294 memset(&plugin, 0, sizeof(struct Plugin));
1298 plugin.cfg = cfg; 1295 plugin.cfg = cfg;
1299 api = GNUNET_new (struct GNUNET_REST_Plugin); 1296 api = GNUNET_new(struct GNUNET_REST_Plugin);
1300 api->cls = &plugin; 1297 api->cls = &plugin;
1301 api->name = GNUNET_REST_API_NS_IDENTITY; 1298 api->name = GNUNET_REST_API_NS_IDENTITY;
1302 api->process_request = &rest_process_request; 1299 api->process_request = &rest_process_request;
1303 GNUNET_asprintf (&allow_methods, 1300 GNUNET_asprintf(&allow_methods,
1304 "%s, %s, %s, %s, %s", 1301 "%s, %s, %s, %s, %s",
1305 MHD_HTTP_METHOD_GET, 1302 MHD_HTTP_METHOD_GET,
1306 MHD_HTTP_METHOD_POST, 1303 MHD_HTTP_METHOD_POST,
1307 MHD_HTTP_METHOD_PUT, 1304 MHD_HTTP_METHOD_PUT,
1308 MHD_HTTP_METHOD_DELETE, 1305 MHD_HTTP_METHOD_DELETE,
1309 MHD_HTTP_METHOD_OPTIONS); 1306 MHD_HTTP_METHOD_OPTIONS);
1310 1307
1311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n")); 1308 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Identity REST API initialized\n"));
1312 return api; 1309 return api;
1313} 1310}
1314 1311
@@ -1319,15 +1316,16 @@ libgnunet_plugin_rest_identity_init (void *cls)
1319 * @return always NULL 1316 * @return always NULL
1320 */ 1317 */
1321void * 1318void *
1322libgnunet_plugin_rest_identity_done (void *cls) 1319libgnunet_plugin_rest_identity_done(void *cls)
1323{ 1320{
1324 struct GNUNET_REST_Plugin *api = cls; 1321 struct GNUNET_REST_Plugin *api = cls;
1325 struct Plugin *plugin = api->cls; 1322 struct Plugin *plugin = api->cls;
1323
1326 plugin->cfg = NULL; 1324 plugin->cfg = NULL;
1327 1325
1328 GNUNET_free_non_null (allow_methods); 1326 GNUNET_free_non_null(allow_methods);
1329 GNUNET_free (api); 1327 GNUNET_free(api);
1330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n"); 1328 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n");
1331 return NULL; 1329 return NULL;
1332} 1330}
1333 1331