diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-07-15 14:19:38 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-07-15 14:19:38 +0200 |
commit | febfb2408227b432e0455f62590cda628323437a (patch) | |
tree | ecfd4e0e79f96acae764b0d08630dbddda5d6806 /src/identity/plugin_rest_identity.c | |
parent | eefd54e14a36b9b52b6a6a69224b26093ae5eba8 (diff) | |
download | gnunet-febfb2408227b432e0455f62590cda628323437a.tar.gz gnunet-febfb2408227b432e0455f62590cda628323437a.zip |
enable suspend resume for REST
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r-- | src/identity/plugin_rest_identity.c | 455 |
1 files changed, 229 insertions, 226 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index e6537070a..ac1965a75 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -124,7 +124,7 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
124 | /** | 124 | /** |
125 | * HTTP methods allows for this plugin | 125 | * HTTP methods allows for this plugin |
126 | */ | 126 | */ |
127 | static char* allow_methods; | 127 | static char *allow_methods; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * @brief struct returned by the initialization function of the plugin | 130 | * @brief struct returned by the initialization function of the plugin |
@@ -173,7 +173,7 @@ struct RequestHandle | |||
173 | /** | 173 | /** |
174 | * The data from the REST request | 174 | * The data from the REST request |
175 | */ | 175 | */ |
176 | const char* data; | 176 | const char *data; |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * The name to look up | 179 | * The name to look up |
@@ -250,7 +250,6 @@ struct RequestHandle | |||
250 | * Response code | 250 | * Response code |
251 | */ | 251 | */ |
252 | int response_code; | 252 | int response_code; |
253 | |||
254 | }; | 253 | }; |
255 | 254 | ||
256 | /** | 255 | /** |
@@ -264,7 +263,7 @@ cleanup_handle (void *cls) | |||
264 | struct EgoEntry *ego_entry; | 263 | struct EgoEntry *ego_entry; |
265 | struct EgoEntry *ego_tmp; | 264 | struct EgoEntry *ego_tmp; |
266 | 265 | ||
267 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); | 266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); |
268 | if (NULL != handle->timeout_task) | 267 | if (NULL != handle->timeout_task) |
269 | { | 268 | { |
270 | GNUNET_SCHEDULER_cancel (handle->timeout_task); | 269 | GNUNET_SCHEDULER_cancel (handle->timeout_task); |
@@ -272,25 +271,24 @@ cleanup_handle (void *cls) | |||
272 | } | 271 | } |
273 | 272 | ||
274 | if (NULL != handle->url) | 273 | if (NULL != handle->url) |
275 | GNUNET_free(handle->url); | 274 | GNUNET_free (handle->url); |
276 | if (NULL != handle->emsg) | 275 | if (NULL != handle->emsg) |
277 | GNUNET_free(handle->emsg); | 276 | GNUNET_free (handle->emsg); |
278 | if (NULL != handle->name) | 277 | if (NULL != handle->name) |
279 | GNUNET_free (handle->name); | 278 | GNUNET_free (handle->name); |
280 | if (NULL != handle->identity_handle) | 279 | if (NULL != handle->identity_handle) |
281 | GNUNET_IDENTITY_disconnect (handle->identity_handle); | 280 | GNUNET_IDENTITY_disconnect (handle->identity_handle); |
282 | 281 | ||
283 | for (ego_entry = handle->ego_head; | 282 | for (ego_entry = handle->ego_head; NULL != ego_entry;) |
284 | NULL != ego_entry;) | ||
285 | { | 283 | { |
286 | ego_tmp = ego_entry; | 284 | ego_tmp = ego_entry; |
287 | ego_entry = ego_entry->next; | 285 | ego_entry = ego_entry->next; |
288 | GNUNET_free(ego_tmp->identifier); | 286 | GNUNET_free (ego_tmp->identifier); |
289 | GNUNET_free(ego_tmp->keystring); | 287 | GNUNET_free (ego_tmp->keystring); |
290 | GNUNET_free(ego_tmp); | 288 | GNUNET_free (ego_tmp); |
291 | } | 289 | } |
292 | 290 | ||
293 | GNUNET_free(handle); | 291 | GNUNET_free (handle); |
294 | } | 292 | } |
295 | 293 | ||
296 | /** | 294 | /** |
@@ -303,26 +301,25 @@ do_error (void *cls) | |||
303 | { | 301 | { |
304 | struct RequestHandle *handle = cls; | 302 | struct RequestHandle *handle = cls; |
305 | struct MHD_Response *resp; | 303 | struct MHD_Response *resp; |
306 | json_t *json_error = json_object(); | 304 | json_t *json_error = json_object (); |
307 | char *response; | 305 | char *response; |
308 | 306 | ||
309 | if (NULL == handle->emsg) | 307 | if (NULL == handle->emsg) |
310 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_ERROR_UNKNOWN); | 308 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_ERROR_UNKNOWN); |
311 | 309 | ||
312 | json_object_set_new(json_error,"error", json_string(handle->emsg)); | 310 | json_object_set_new (json_error, "error", json_string (handle->emsg)); |
313 | 311 | ||
314 | if (0 == handle->response_code) | 312 | if (0 == handle->response_code) |
315 | handle->response_code = MHD_HTTP_OK; | 313 | handle->response_code = MHD_HTTP_OK; |
316 | response = json_dumps (json_error, 0); | 314 | response = json_dumps (json_error, 0); |
317 | resp = GNUNET_REST_create_response (response); | 315 | resp = GNUNET_REST_create_response (response); |
318 | handle->proc (handle->proc_cls, resp, handle->response_code); | 316 | handle->proc (handle->proc_cls, resp, handle->response_code); |
319 | json_decref(json_error); | 317 | json_decref (json_error); |
320 | GNUNET_free(response); | 318 | GNUNET_free (response); |
321 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 319 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
322 | } | 320 | } |
323 | 321 | ||
324 | 322 | ||
325 | |||
326 | /** | 323 | /** |
327 | * Get EgoEntry from list with either a public key or a name | 324 | * Get EgoEntry from list with either a public key or a name |
328 | * If public key and name are not NULL, it returns the public key result first | 325 | * If public key and name are not NULL, it returns the public key result first |
@@ -332,29 +329,27 @@ do_error (void *cls) | |||
332 | * @param name the name of an identity (only one can be NULL) | 329 | * @param name the name of an identity (only one can be NULL) |
333 | * @return EgoEntry or NULL if not found | 330 | * @return EgoEntry or NULL if not found |
334 | */ | 331 | */ |
335 | struct EgoEntry* | 332 | struct EgoEntry * |
336 | get_egoentry(struct RequestHandle *handle, char* pubkey, char *name) | 333 | get_egoentry (struct RequestHandle *handle, char *pubkey, char *name) |
337 | { | 334 | { |
338 | struct EgoEntry *ego_entry; | 335 | struct EgoEntry *ego_entry; |
339 | if (NULL != pubkey) | 336 | if (NULL != pubkey) |
340 | { | 337 | { |
341 | for (ego_entry = handle->ego_head; | 338 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
342 | NULL != ego_entry; | 339 | ego_entry = ego_entry->next) |
343 | ego_entry = ego_entry->next) | ||
344 | { | 340 | { |
345 | if (0 != strcasecmp (pubkey, ego_entry->keystring)) | 341 | if (0 != strcasecmp (pubkey, ego_entry->keystring)) |
346 | continue; | 342 | continue; |
347 | return ego_entry; | 343 | return ego_entry; |
348 | } | 344 | } |
349 | } | 345 | } |
350 | if (NULL != name) | 346 | if (NULL != name) |
351 | { | 347 | { |
352 | for (ego_entry = handle->ego_head; | 348 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
353 | NULL != ego_entry; | 349 | ego_entry = ego_entry->next) |
354 | ego_entry = ego_entry->next) | ||
355 | { | 350 | { |
356 | if (0 != strcasecmp (name, ego_entry->identifier)) | 351 | if (0 != strcasecmp (name, ego_entry->identifier)) |
357 | continue; | 352 | continue; |
358 | return ego_entry; | 353 | return ego_entry; |
359 | } | 354 | } |
360 | } | 355 | } |
@@ -372,9 +367,9 @@ get_egoentry(struct RequestHandle *handle, char* pubkey, char *name) | |||
372 | */ | 367 | */ |
373 | static void | 368 | static void |
374 | ego_get_for_subsystem (void *cls, | 369 | ego_get_for_subsystem (void *cls, |
375 | struct GNUNET_IDENTITY_Ego *ego, | 370 | struct GNUNET_IDENTITY_Ego *ego, |
376 | void **ctx, | 371 | void **ctx, |
377 | const char *name) | 372 | const char *name) |
378 | { | 373 | { |
379 | struct RequestHandle *handle = cls; | 374 | struct RequestHandle *handle = cls; |
380 | struct MHD_Response *resp; | 375 | struct MHD_Response *resp; |
@@ -383,34 +378,34 @@ ego_get_for_subsystem (void *cls, | |||
383 | char *result_str; | 378 | char *result_str; |
384 | char *public_key_string; | 379 | char *public_key_string; |
385 | 380 | ||
386 | if(NULL == ego) | 381 | if (NULL == ego) |
387 | { | 382 | { |
388 | handle->response_code = MHD_HTTP_NOT_FOUND; | 383 | handle->response_code = MHD_HTTP_NOT_FOUND; |
389 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 384 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
390 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 385 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
391 | return; | 386 | return; |
392 | } | 387 | } |
393 | 388 | ||
394 | GNUNET_IDENTITY_ego_get_public_key(ego,&public_key); | 389 | GNUNET_IDENTITY_ego_get_public_key (ego, &public_key); |
395 | public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string(&public_key); | 390 | public_key_string = GNUNET_CRYPTO_ecdsa_public_key_to_string (&public_key); |
396 | 391 | ||
397 | // create json with subsystem identity | 392 | // create json with subsystem identity |
398 | json_root = json_object (); | 393 | json_root = json_object (); |
399 | json_object_set_new (json_root, | 394 | json_object_set_new (json_root, |
400 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, | 395 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, |
401 | json_string(public_key_string)); | 396 | json_string (public_key_string)); |
402 | json_object_set_new (json_root, | 397 | json_object_set_new (json_root, |
403 | GNUNET_REST_IDENTITY_PARAM_NAME, | 398 | GNUNET_REST_IDENTITY_PARAM_NAME, |
404 | json_string(name)); | 399 | json_string (name)); |
405 | 400 | ||
406 | result_str = json_dumps (json_root, 0); | 401 | result_str = json_dumps (json_root, 0); |
407 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
408 | resp = GNUNET_REST_create_response (result_str); | 403 | resp = GNUNET_REST_create_response (result_str); |
409 | 404 | ||
410 | json_decref (json_root); | 405 | json_decref (json_root); |
411 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 406 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
412 | GNUNET_free(result_str); | 407 | GNUNET_free (result_str); |
413 | GNUNET_free(public_key_string); | 408 | GNUNET_free (public_key_string); |
414 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 409 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
415 | } | 410 | } |
416 | 411 | ||
@@ -423,32 +418,31 @@ ego_get_for_subsystem (void *cls, | |||
423 | */ | 418 | */ |
424 | void | 419 | void |
425 | ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | 420 | ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle, |
426 | const char* url, | 421 | const char *url, |
427 | void *cls) | 422 | void *cls) |
428 | { | 423 | { |
429 | struct RequestHandle *handle = cls; | 424 | struct RequestHandle *handle = cls; |
430 | char *subsystem; | 425 | char *subsystem; |
431 | 426 | ||
432 | if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) | 427 | if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) |
433 | { | 428 | { |
434 | handle->emsg = GNUNET_strdup("Missing subsystem name"); | 429 | handle->emsg = GNUNET_strdup ("Missing subsystem name"); |
435 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 430 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
436 | return; | 431 | return; |
437 | } | 432 | } |
438 | subsystem = &handle->url[strlen ( | 433 | subsystem = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; |
439 | GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; | ||
440 | //requested default identity of subsystem | 434 | //requested default identity of subsystem |
441 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem); | 435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem); |
442 | 436 | ||
443 | handle->op = GNUNET_IDENTITY_get (handle->identity_handle, | 437 | handle->op = GNUNET_IDENTITY_get (handle->identity_handle, |
444 | subsystem, | 438 | subsystem, |
445 | &ego_get_for_subsystem, | 439 | &ego_get_for_subsystem, |
446 | handle); | 440 | handle); |
447 | 441 | ||
448 | if (NULL == handle->op) | 442 | if (NULL == handle->op) |
449 | { | 443 | { |
450 | handle->response_code = MHD_HTTP_NOT_FOUND; | 444 | handle->response_code = MHD_HTTP_NOT_FOUND; |
451 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 445 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
452 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 446 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
453 | return; | 447 | return; |
454 | } | 448 | } |
@@ -464,8 +458,8 @@ ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
464 | */ | 458 | */ |
465 | void | 459 | void |
466 | ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, | 460 | ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, |
467 | const char* url, | 461 | const char *url, |
468 | void *cls) | 462 | void *cls) |
469 | { | 463 | { |
470 | struct RequestHandle *handle = cls; | 464 | struct RequestHandle *handle = cls; |
471 | struct EgoEntry *ego_entry; | 465 | struct EgoEntry *ego_entry; |
@@ -476,27 +470,27 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle, | |||
476 | 470 | ||
477 | json_root = json_array (); | 471 | json_root = json_array (); |
478 | //Return ego/egos | 472 | //Return ego/egos |
479 | for (ego_entry = handle->ego_head; | 473 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
480 | NULL != ego_entry; ego_entry = ego_entry->next) | 474 | ego_entry = ego_entry->next) |
481 | { | 475 | { |
482 | json_ego = json_object (); | 476 | json_ego = json_object (); |
483 | json_object_set_new (json_ego, | 477 | json_object_set_new (json_ego, |
484 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, | 478 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, |
485 | json_string (ego_entry->keystring)); | 479 | json_string (ego_entry->keystring)); |
486 | json_object_set_new (json_ego, | 480 | json_object_set_new (json_ego, |
487 | GNUNET_REST_IDENTITY_PARAM_NAME, | 481 | GNUNET_REST_IDENTITY_PARAM_NAME, |
488 | json_string (ego_entry->identifier)); | 482 | json_string (ego_entry->identifier)); |
489 | json_array_append (json_root, json_ego); | 483 | json_array_append (json_root, json_ego); |
490 | json_decref (json_ego); | 484 | json_decref (json_ego); |
491 | } | 485 | } |
492 | 486 | ||
493 | result_str = json_dumps (json_root, 0); | 487 | result_str = json_dumps (json_root, 0); |
494 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
495 | resp = GNUNET_REST_create_response (result_str); | 489 | resp = GNUNET_REST_create_response (result_str); |
496 | 490 | ||
497 | json_decref (json_root); | 491 | json_decref (json_root); |
498 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 492 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
499 | GNUNET_free(result_str); | 493 | GNUNET_free (result_str); |
500 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 494 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
501 | } | 495 | } |
502 | 496 | ||
@@ -516,19 +510,19 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
516 | 510 | ||
517 | json_ego = json_object (); | 511 | json_ego = json_object (); |
518 | json_object_set_new (json_ego, | 512 | json_object_set_new (json_ego, |
519 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, | 513 | GNUNET_REST_IDENTITY_PARAM_PUBKEY, |
520 | json_string (ego_entry->keystring)); | 514 | json_string (ego_entry->keystring)); |
521 | json_object_set_new (json_ego, | 515 | json_object_set_new (json_ego, |
522 | GNUNET_REST_IDENTITY_PARAM_NAME, | 516 | GNUNET_REST_IDENTITY_PARAM_NAME, |
523 | json_string (ego_entry->identifier)); | 517 | json_string (ego_entry->identifier)); |
524 | 518 | ||
525 | result_str = json_dumps (json_ego, 0); | 519 | result_str = json_dumps (json_ego, 0); |
526 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
527 | resp = GNUNET_REST_create_response (result_str); | 521 | resp = GNUNET_REST_create_response (result_str); |
528 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 522 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
529 | 523 | ||
530 | json_decref (json_ego); | 524 | json_decref (json_ego); |
531 | GNUNET_free(result_str); | 525 | GNUNET_free (result_str); |
532 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 526 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
533 | } | 527 | } |
534 | 528 | ||
@@ -542,8 +536,8 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
542 | */ | 536 | */ |
543 | void | 537 | void |
544 | ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | 538 | ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle, |
545 | const char* url, | 539 | const char *url, |
546 | void *cls) | 540 | void *cls) |
547 | { | 541 | { |
548 | struct RequestHandle *handle = cls; | 542 | struct RequestHandle *handle = cls; |
549 | struct EgoEntry *ego_entry; | 543 | struct EgoEntry *ego_entry; |
@@ -554,22 +548,22 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
554 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) | 548 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) |
555 | { | 549 | { |
556 | handle->response_code = MHD_HTTP_NOT_FOUND; | 550 | handle->response_code = MHD_HTTP_NOT_FOUND; |
557 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); | 551 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); |
558 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 552 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
559 | return; | 553 | return; |
560 | } | 554 | } |
561 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1]; | 555 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; |
562 | ego_entry = get_egoentry(handle, keystring, NULL); | 556 | ego_entry = get_egoentry (handle, keystring, NULL); |
563 | 557 | ||
564 | if (NULL == ego_entry) | 558 | if (NULL == ego_entry) |
565 | { | 559 | { |
566 | handle->response_code = MHD_HTTP_NOT_FOUND; | 560 | handle->response_code = MHD_HTTP_NOT_FOUND; |
567 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 561 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
568 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 562 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
569 | return; | 563 | return; |
570 | } | 564 | } |
571 | 565 | ||
572 | ego_get_response(handle, ego_entry); | 566 | ego_get_response (handle, ego_entry); |
573 | } | 567 | } |
574 | 568 | ||
575 | /** | 569 | /** |
@@ -581,8 +575,8 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
581 | */ | 575 | */ |
582 | void | 576 | void |
583 | ego_get_name (struct GNUNET_REST_RequestHandle *con_handle, | 577 | ego_get_name (struct GNUNET_REST_RequestHandle *con_handle, |
584 | const char* url, | 578 | const char *url, |
585 | void *cls) | 579 | void *cls) |
586 | { | 580 | { |
587 | struct RequestHandle *handle = cls; | 581 | struct RequestHandle *handle = cls; |
588 | struct EgoEntry *ego_entry; | 582 | struct EgoEntry *ego_entry; |
@@ -593,22 +587,22 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle, | |||
593 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) | 587 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) |
594 | { | 588 | { |
595 | handle->response_code = MHD_HTTP_NOT_FOUND; | 589 | handle->response_code = MHD_HTTP_NOT_FOUND; |
596 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); | 590 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); |
597 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 591 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
598 | return; | 592 | return; |
599 | } | 593 | } |
600 | egoname = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1]; | 594 | egoname = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; |
601 | ego_entry = get_egoentry(handle, NULL, egoname); | 595 | ego_entry = get_egoentry (handle, NULL, egoname); |
602 | 596 | ||
603 | if (NULL == ego_entry) | 597 | if (NULL == ego_entry) |
604 | { | 598 | { |
605 | handle->response_code = MHD_HTTP_NOT_FOUND; | 599 | handle->response_code = MHD_HTTP_NOT_FOUND; |
606 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 600 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
607 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 601 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
608 | return; | 602 | return; |
609 | } | 603 | } |
610 | 604 | ||
611 | ego_get_response(handle, ego_entry); | 605 | ego_get_response (handle, ego_entry); |
612 | } | 606 | } |
613 | 607 | ||
614 | 608 | ||
@@ -627,7 +621,7 @@ do_finished (void *cls, const char *emsg) | |||
627 | handle->op = NULL; | 621 | handle->op = NULL; |
628 | if (NULL != emsg) | 622 | if (NULL != emsg) |
629 | { | 623 | { |
630 | handle->emsg = GNUNET_strdup(emsg); | 624 | handle->emsg = GNUNET_strdup (emsg); |
631 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 625 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
632 | return; | 626 | return; |
633 | } | 627 | } |
@@ -650,14 +644,13 @@ do_finished (void *cls, const char *emsg) | |||
650 | */ | 644 | */ |
651 | static void | 645 | static void |
652 | do_finished_create (void *cls, | 646 | do_finished_create (void *cls, |
653 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 647 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, |
654 | const char *emsg) | 648 | const char *emsg) |
655 | { | 649 | { |
656 | struct RequestHandle *handle = cls; | 650 | struct RequestHandle *handle = cls; |
657 | 651 | ||
658 | (void) pk; | 652 | (void) pk; |
659 | do_finished (handle, | 653 | do_finished (handle, emsg); |
660 | emsg); | ||
661 | } | 654 | } |
662 | 655 | ||
663 | 656 | ||
@@ -681,18 +674,18 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
681 | //if no data | 674 | //if no data |
682 | if (0 >= handle->data_size) | 675 | if (0 >= handle->data_size) |
683 | { | 676 | { |
684 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 677 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
685 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 678 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
686 | return; | 679 | return; |
687 | } | 680 | } |
688 | //if not json | 681 | //if not json |
689 | term_data[handle->data_size] = '\0'; | 682 | term_data[handle->data_size] = '\0'; |
690 | GNUNET_memcpy(term_data, handle->data, handle->data_size); | 683 | GNUNET_memcpy (term_data, handle->data, handle->data_size); |
691 | data_js = json_loads (term_data,JSON_DECODE_ANY,&err); | 684 | data_js = json_loads (term_data, JSON_DECODE_ANY, &err); |
692 | 685 | ||
693 | if (NULL == data_js) | 686 | if (NULL == data_js) |
694 | { | 687 | { |
695 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 688 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
696 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 689 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
697 | return; | 690 | return; |
698 | } | 691 | } |
@@ -700,15 +693,15 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
700 | newname = NULL; | 693 | newname = NULL; |
701 | //NEW NAME | 694 | //NEW NAME |
702 | json_state = 0; | 695 | json_state = 0; |
703 | json_state = json_unpack(data_js, | 696 | json_state = json_unpack (data_js, |
704 | "{s:s!}", | 697 | "{s:s!}", |
705 | GNUNET_REST_IDENTITY_PARAM_NEWNAME, | 698 | GNUNET_REST_IDENTITY_PARAM_NEWNAME, |
706 | &newname); | 699 | &newname); |
707 | //Change name with pubkey or name identifier | 700 | //Change name with pubkey or name identifier |
708 | if (0 != json_state) | 701 | if (0 != json_state) |
709 | { | 702 | { |
710 | 703 | ||
711 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 704 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
712 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 705 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
713 | json_decref (data_js); | 706 | json_decref (data_js); |
714 | return; | 707 | return; |
@@ -716,7 +709,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
716 | 709 | ||
717 | if (NULL == newname) | 710 | if (NULL == newname) |
718 | { | 711 | { |
719 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 712 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
720 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 713 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
721 | json_decref (data_js); | 714 | json_decref (data_js); |
722 | return; | 715 | return; |
@@ -724,7 +717,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
724 | 717 | ||
725 | if (0 >= strlen (newname)) | 718 | if (0 >= strlen (newname)) |
726 | { | 719 | { |
727 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 720 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
728 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 721 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
729 | json_decref (data_js); | 722 | json_decref (data_js); |
730 | return; | 723 | return; |
@@ -741,20 +734,19 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
741 | return; | 734 | return; |
742 | } | 735 | } |
743 | handle->op = GNUNET_IDENTITY_rename (handle->identity_handle, | 736 | handle->op = GNUNET_IDENTITY_rename (handle->identity_handle, |
744 | ego_entry->identifier, | 737 | ego_entry->identifier, |
745 | newname, | 738 | newname, |
746 | &do_finished, | 739 | &do_finished, |
747 | handle); | 740 | handle); |
748 | if (NULL == handle->op) | 741 | if (NULL == handle->op) |
749 | { | 742 | { |
750 | handle->emsg = GNUNET_strdup("Rename failed"); | 743 | handle->emsg = GNUNET_strdup ("Rename failed"); |
751 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 744 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
752 | json_decref (data_js); | 745 | json_decref (data_js); |
753 | return; | 746 | return; |
754 | } | 747 | } |
755 | json_decref (data_js); | 748 | json_decref (data_js); |
756 | return; | 749 | return; |
757 | |||
758 | } | 750 | } |
759 | 751 | ||
760 | 752 | ||
@@ -767,8 +759,8 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry) | |||
767 | */ | 759 | */ |
768 | void | 760 | void |
769 | ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | 761 | ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle, |
770 | const char* url, | 762 | const char *url, |
771 | void *cls) | 763 | void *cls) |
772 | { | 764 | { |
773 | struct RequestHandle *handle = cls; | 765 | struct RequestHandle *handle = cls; |
774 | struct EgoEntry *ego_entry; | 766 | struct EgoEntry *ego_entry; |
@@ -779,22 +771,22 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
779 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) | 771 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) |
780 | { | 772 | { |
781 | handle->response_code = MHD_HTTP_NOT_FOUND; | 773 | handle->response_code = MHD_HTTP_NOT_FOUND; |
782 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); | 774 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); |
783 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 775 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
784 | return; | 776 | return; |
785 | } | 777 | } |
786 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1]; | 778 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; |
787 | ego_entry = get_egoentry(handle, keystring, NULL); | 779 | ego_entry = get_egoentry (handle, keystring, NULL); |
788 | 780 | ||
789 | if (NULL == ego_entry) | 781 | if (NULL == ego_entry) |
790 | { | 782 | { |
791 | handle->response_code = MHD_HTTP_NOT_FOUND; | 783 | handle->response_code = MHD_HTTP_NOT_FOUND; |
792 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 784 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
793 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 785 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
794 | return; | 786 | return; |
795 | } | 787 | } |
796 | 788 | ||
797 | ego_edit(handle,ego_entry); | 789 | ego_edit (handle, ego_entry); |
798 | } | 790 | } |
799 | 791 | ||
800 | /** | 792 | /** |
@@ -806,8 +798,8 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
806 | */ | 798 | */ |
807 | void | 799 | void |
808 | ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle, | 800 | ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle, |
809 | const char* url, | 801 | const char *url, |
810 | void *cls) | 802 | void *cls) |
811 | { | 803 | { |
812 | struct RequestHandle *handle = cls; | 804 | struct RequestHandle *handle = cls; |
813 | struct EgoEntry *ego_entry; | 805 | struct EgoEntry *ego_entry; |
@@ -818,22 +810,22 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle, | |||
818 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) | 810 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) |
819 | { | 811 | { |
820 | handle->response_code = MHD_HTTP_NOT_FOUND; | 812 | handle->response_code = MHD_HTTP_NOT_FOUND; |
821 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); | 813 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); |
822 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 814 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
823 | return; | 815 | return; |
824 | } | 816 | } |
825 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1]; | 817 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; |
826 | ego_entry = get_egoentry(handle, NULL, name); | 818 | ego_entry = get_egoentry (handle, NULL, name); |
827 | 819 | ||
828 | if (NULL == ego_entry) | 820 | if (NULL == ego_entry) |
829 | { | 821 | { |
830 | handle->response_code = MHD_HTTP_NOT_FOUND; | 822 | handle->response_code = MHD_HTTP_NOT_FOUND; |
831 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 823 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
832 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 824 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
833 | return; | 825 | return; |
834 | } | 826 | } |
835 | 827 | ||
836 | ego_edit(handle,ego_entry); | 828 | ego_edit (handle, ego_entry); |
837 | } | 829 | } |
838 | 830 | ||
839 | /** | 831 | /** |
@@ -845,8 +837,8 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle, | |||
845 | */ | 837 | */ |
846 | void | 838 | void |
847 | ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | 839 | ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, |
848 | const char* url, | 840 | const char *url, |
849 | void *cls) | 841 | void *cls) |
850 | { | 842 | { |
851 | struct RequestHandle *handle = cls; | 843 | struct RequestHandle *handle = cls; |
852 | struct EgoEntry *ego_entry; | 844 | struct EgoEntry *ego_entry; |
@@ -862,17 +854,17 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
862 | if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) | 854 | if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url)) |
863 | { | 855 | { |
864 | handle->response_code = MHD_HTTP_NOT_FOUND; | 856 | handle->response_code = MHD_HTTP_NOT_FOUND; |
865 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); | 857 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); |
866 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 858 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
867 | return; | 859 | return; |
868 | } | 860 | } |
869 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM)+1]; | 861 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1]; |
870 | ego_entry = get_egoentry(handle, NULL, name); | 862 | ego_entry = get_egoentry (handle, NULL, name); |
871 | 863 | ||
872 | if (NULL == ego_entry) | 864 | if (NULL == ego_entry) |
873 | { | 865 | { |
874 | handle->response_code = MHD_HTTP_NOT_FOUND; | 866 | handle->response_code = MHD_HTTP_NOT_FOUND; |
875 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 867 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
876 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 868 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
877 | return; | 869 | return; |
878 | } | 870 | } |
@@ -880,18 +872,18 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
880 | //if no data | 872 | //if no data |
881 | if (0 >= handle->data_size) | 873 | if (0 >= handle->data_size) |
882 | { | 874 | { |
883 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 875 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
884 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 876 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
885 | return; | 877 | return; |
886 | } | 878 | } |
887 | //if not json | 879 | //if not json |
888 | term_data[handle->data_size] = '\0'; | 880 | term_data[handle->data_size] = '\0'; |
889 | GNUNET_memcpy(term_data, handle->data, handle->data_size); | 881 | GNUNET_memcpy (term_data, handle->data, handle->data_size); |
890 | data_js = json_loads (term_data,JSON_DECODE_ANY,&err); | 882 | data_js = json_loads (term_data, JSON_DECODE_ANY, &err); |
891 | 883 | ||
892 | if (NULL == data_js) | 884 | if (NULL == data_js) |
893 | { | 885 | { |
894 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 886 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
895 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 887 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
896 | return; | 888 | return; |
897 | } | 889 | } |
@@ -899,14 +891,14 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
899 | newsubsys = NULL; | 891 | newsubsys = NULL; |
900 | //SUBSYSTEM | 892 | //SUBSYSTEM |
901 | json_state = 0; | 893 | json_state = 0; |
902 | json_state = json_unpack(data_js, | 894 | json_state = json_unpack (data_js, |
903 | "{s:s!}", | 895 | "{s:s!}", |
904 | GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM, | 896 | GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM, |
905 | &newsubsys); | 897 | &newsubsys); |
906 | //Change subsystem with pubkey or name identifier | 898 | //Change subsystem with pubkey or name identifier |
907 | if (0 != json_state) | 899 | if (0 != json_state) |
908 | { | 900 | { |
909 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 901 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
910 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 902 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
911 | json_decref (data_js); | 903 | json_decref (data_js); |
912 | return; | 904 | return; |
@@ -914,7 +906,7 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
914 | 906 | ||
915 | if (NULL == newsubsys) | 907 | if (NULL == newsubsys) |
916 | { | 908 | { |
917 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 909 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
918 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 910 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
919 | json_decref (data_js); | 911 | json_decref (data_js); |
920 | return; | 912 | return; |
@@ -922,7 +914,7 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
922 | 914 | ||
923 | if (0 >= strlen (newsubsys)) | 915 | if (0 >= strlen (newsubsys)) |
924 | { | 916 | { |
925 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 917 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
926 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 918 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
927 | json_decref (data_js); | 919 | json_decref (data_js); |
928 | return; | 920 | return; |
@@ -930,19 +922,18 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
930 | 922 | ||
931 | handle->response_code = MHD_HTTP_NO_CONTENT; | 923 | handle->response_code = MHD_HTTP_NO_CONTENT; |
932 | handle->op = GNUNET_IDENTITY_set (handle->identity_handle, | 924 | handle->op = GNUNET_IDENTITY_set (handle->identity_handle, |
933 | newsubsys, | 925 | newsubsys, |
934 | ego_entry->ego, | 926 | ego_entry->ego, |
935 | &do_finished, | 927 | &do_finished, |
936 | handle); | 928 | handle); |
937 | if (NULL == handle->op) | 929 | if (NULL == handle->op) |
938 | { | 930 | { |
939 | handle->emsg = GNUNET_strdup("Setting subsystem failed"); | 931 | handle->emsg = GNUNET_strdup ("Setting subsystem failed"); |
940 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 932 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
941 | return; | 933 | return; |
942 | } | 934 | } |
943 | json_decref (data_js); | 935 | json_decref (data_js); |
944 | return; | 936 | return; |
945 | |||
946 | } | 937 | } |
947 | 938 | ||
948 | /** | 939 | /** |
@@ -954,15 +945,15 @@ ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle, | |||
954 | */ | 945 | */ |
955 | void | 946 | void |
956 | ego_create (struct GNUNET_REST_RequestHandle *con_handle, | 947 | ego_create (struct GNUNET_REST_RequestHandle *con_handle, |
957 | const char* url, | 948 | const char *url, |
958 | void *cls) | 949 | void *cls) |
959 | { | 950 | { |
960 | struct RequestHandle *handle = cls; | 951 | struct RequestHandle *handle = cls; |
961 | struct EgoEntry *ego_entry; | 952 | struct EgoEntry *ego_entry; |
962 | struct MHD_Response *resp; | 953 | struct MHD_Response *resp; |
963 | json_t *data_js; | 954 | json_t *data_js; |
964 | json_error_t err; | 955 | json_error_t err; |
965 | char* egoname; | 956 | char *egoname; |
966 | int json_unpack_state; | 957 | int json_unpack_state; |
967 | char term_data[handle->data_size + 1]; | 958 | char term_data[handle->data_size + 1]; |
968 | 959 | ||
@@ -974,30 +965,26 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
974 | 965 | ||
975 | if (0 >= handle->data_size) | 966 | if (0 >= handle->data_size) |
976 | { | 967 | { |
977 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 968 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
978 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 969 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
979 | return; | 970 | return; |
980 | } | 971 | } |
981 | term_data[handle->data_size] = '\0'; | 972 | term_data[handle->data_size] = '\0'; |
982 | GNUNET_memcpy(term_data, handle->data, handle->data_size); | 973 | GNUNET_memcpy (term_data, handle->data, handle->data_size); |
983 | data_js = json_loads (term_data, | 974 | data_js = json_loads (term_data, JSON_DECODE_ANY, &err); |
984 | JSON_DECODE_ANY, | ||
985 | &err); | ||
986 | if (NULL == data_js) | 975 | if (NULL == data_js) |
987 | { | 976 | { |
988 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA); | 977 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA); |
989 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 978 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
990 | json_decref (data_js); | 979 | json_decref (data_js); |
991 | return; | 980 | return; |
992 | } | 981 | } |
993 | json_unpack_state = 0; | 982 | json_unpack_state = 0; |
994 | json_unpack_state = json_unpack(data_js, | 983 | json_unpack_state = |
995 | "{s:s!}", | 984 | json_unpack (data_js, "{s:s!}", GNUNET_REST_IDENTITY_PARAM_NAME, &egoname); |
996 | GNUNET_REST_IDENTITY_PARAM_NAME, | ||
997 | &egoname); | ||
998 | if (0 != json_unpack_state) | 985 | if (0 != json_unpack_state) |
999 | { | 986 | { |
1000 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 987 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
1001 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 988 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1002 | json_decref (data_js); | 989 | json_decref (data_js); |
1003 | return; | 990 | return; |
@@ -1005,7 +992,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1005 | 992 | ||
1006 | if (NULL == egoname) | 993 | if (NULL == egoname) |
1007 | { | 994 | { |
1008 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 995 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
1009 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 996 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1010 | json_decref (data_js); | 997 | json_decref (data_js); |
1011 | return; | 998 | return; |
@@ -1013,13 +1000,13 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1013 | if (0 >= strlen (egoname)) | 1000 | if (0 >= strlen (egoname)) |
1014 | { | 1001 | { |
1015 | json_decref (data_js); | 1002 | json_decref (data_js); |
1016 | handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID); | 1003 | handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID); |
1017 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1004 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1018 | return; | 1005 | return; |
1019 | } | 1006 | } |
1020 | GNUNET_STRINGS_utf8_tolower(egoname, egoname); | 1007 | GNUNET_STRINGS_utf8_tolower (egoname, egoname); |
1021 | for (ego_entry = handle->ego_head; | 1008 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
1022 | NULL != ego_entry; ego_entry = ego_entry->next) | 1009 | ego_entry = ego_entry->next) |
1023 | { | 1010 | { |
1024 | if (0 == strcasecmp (egoname, ego_entry->identifier)) | 1011 | if (0 == strcasecmp (egoname, ego_entry->identifier)) |
1025 | { | 1012 | { |
@@ -1030,11 +1017,13 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1030 | return; | 1017 | return; |
1031 | } | 1018 | } |
1032 | } | 1019 | } |
1033 | handle->name = GNUNET_strdup(egoname); | 1020 | handle->name = GNUNET_strdup (egoname); |
1034 | json_decref (data_js); | 1021 | json_decref (data_js); |
1035 | handle->response_code = MHD_HTTP_CREATED; | 1022 | handle->response_code = MHD_HTTP_CREATED; |
1036 | handle->op = GNUNET_IDENTITY_create (handle->identity_handle, handle->name, | 1023 | handle->op = GNUNET_IDENTITY_create (handle->identity_handle, |
1037 | &do_finished_create, handle); | 1024 | handle->name, |
1025 | &do_finished_create, | ||
1026 | handle); | ||
1038 | } | 1027 | } |
1039 | 1028 | ||
1040 | /** | 1029 | /** |
@@ -1046,8 +1035,8 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, | |||
1046 | */ | 1035 | */ |
1047 | void | 1036 | void |
1048 | ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | 1037 | ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle, |
1049 | const char* url, | 1038 | const char *url, |
1050 | void *cls) | 1039 | void *cls) |
1051 | { | 1040 | { |
1052 | struct RequestHandle *handle = cls; | 1041 | struct RequestHandle *handle = cls; |
1053 | struct EgoEntry *ego_entry; | 1042 | struct EgoEntry *ego_entry; |
@@ -1058,26 +1047,26 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
1058 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) | 1047 | if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url)) |
1059 | { | 1048 | { |
1060 | handle->response_code = MHD_HTTP_NOT_FOUND; | 1049 | handle->response_code = MHD_HTTP_NOT_FOUND; |
1061 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY); | 1050 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY); |
1062 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1051 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1063 | return; | 1052 | return; |
1064 | } | 1053 | } |
1065 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1]; | 1054 | keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) + 1]; |
1066 | ego_entry = get_egoentry(handle, keystring, NULL); | 1055 | ego_entry = get_egoentry (handle, keystring, NULL); |
1067 | 1056 | ||
1068 | if (NULL == ego_entry) | 1057 | if (NULL == ego_entry) |
1069 | { | 1058 | { |
1070 | handle->response_code = MHD_HTTP_NOT_FOUND; | 1059 | handle->response_code = MHD_HTTP_NOT_FOUND; |
1071 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 1060 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
1072 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1061 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1073 | return; | 1062 | return; |
1074 | } | 1063 | } |
1075 | 1064 | ||
1076 | handle->response_code = MHD_HTTP_NO_CONTENT; | 1065 | handle->response_code = MHD_HTTP_NO_CONTENT; |
1077 | handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, | 1066 | handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, |
1078 | ego_entry->identifier, | 1067 | ego_entry->identifier, |
1079 | &do_finished, | 1068 | &do_finished, |
1080 | handle); | 1069 | handle); |
1081 | } | 1070 | } |
1082 | 1071 | ||
1083 | 1072 | ||
@@ -1090,8 +1079,8 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle, | |||
1090 | */ | 1079 | */ |
1091 | void | 1080 | void |
1092 | ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle, | 1081 | ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle, |
1093 | const char* url, | 1082 | const char *url, |
1094 | void *cls) | 1083 | void *cls) |
1095 | { | 1084 | { |
1096 | struct RequestHandle *handle = cls; | 1085 | struct RequestHandle *handle = cls; |
1097 | struct EgoEntry *ego_entry; | 1086 | struct EgoEntry *ego_entry; |
@@ -1102,26 +1091,26 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle, | |||
1102 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) | 1091 | if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url)) |
1103 | { | 1092 | { |
1104 | handle->response_code = MHD_HTTP_NOT_FOUND; | 1093 | handle->response_code = MHD_HTTP_NOT_FOUND; |
1105 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME); | 1094 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME); |
1106 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1095 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1107 | return; | 1096 | return; |
1108 | } | 1097 | } |
1109 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1]; | 1098 | name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME) + 1]; |
1110 | ego_entry = get_egoentry(handle, NULL, name); | 1099 | ego_entry = get_egoentry (handle, NULL, name); |
1111 | 1100 | ||
1112 | if (NULL == ego_entry) | 1101 | if (NULL == ego_entry) |
1113 | { | 1102 | { |
1114 | handle->response_code = MHD_HTTP_NOT_FOUND; | 1103 | handle->response_code = MHD_HTTP_NOT_FOUND; |
1115 | handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND); | 1104 | handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND); |
1116 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1105 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1117 | return; | 1106 | return; |
1118 | } | 1107 | } |
1119 | 1108 | ||
1120 | handle->response_code = MHD_HTTP_NO_CONTENT; | 1109 | handle->response_code = MHD_HTTP_NO_CONTENT; |
1121 | handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, | 1110 | handle->op = GNUNET_IDENTITY_delete (handle->identity_handle, |
1122 | ego_entry->identifier, | 1111 | ego_entry->identifier, |
1123 | &do_finished, | 1112 | &do_finished, |
1124 | handle); | 1113 | handle); |
1125 | } | 1114 | } |
1126 | 1115 | ||
1127 | 1116 | ||
@@ -1133,8 +1122,9 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle, | |||
1133 | * @param cls the RequestHandle | 1122 | * @param cls the RequestHandle |
1134 | */ | 1123 | */ |
1135 | static void | 1124 | static void |
1136 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char* url, | 1125 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
1137 | void *cls) | 1126 | const char *url, |
1127 | void *cls) | ||
1138 | { | 1128 | { |
1139 | struct MHD_Response *resp; | 1129 | struct MHD_Response *resp; |
1140 | struct RequestHandle *handle = cls; | 1130 | struct RequestHandle *handle = cls; |
@@ -1156,24 +1146,32 @@ static void | |||
1156 | init_cont (struct RequestHandle *handle) | 1146 | init_cont (struct RequestHandle *handle) |
1157 | { | 1147 | { |
1158 | struct GNUNET_REST_RequestHandlerError err; | 1148 | struct GNUNET_REST_RequestHandlerError err; |
1159 | static const struct GNUNET_REST_RequestHandler handlers[] = { | 1149 | static const struct GNUNET_REST_RequestHandler handlers[] = |
1160 | { 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}, |
1161 | { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey }, | 1151 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey}, |
1162 | { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name }, | 1152 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name}, |
1163 | { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, &ego_get_subsystem }, | 1153 | {MHD_HTTP_METHOD_GET, |
1164 | { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_edit_pubkey }, | 1154 | GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, |
1165 | { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name }, | 1155 | &ego_get_subsystem}, |
1166 | { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, &ego_edit_subsystem }, | 1156 | {MHD_HTTP_METHOD_PUT, |
1167 | { MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create }, | 1157 | GNUNET_REST_API_NS_IDENTITY_PUBKEY, |
1168 | { MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_delete_pubkey }, | 1158 | &ego_edit_pubkey}, |
1169 | { MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_delete_name }, | 1159 | {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name}, |
1170 | { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont }, | 1160 | {MHD_HTTP_METHOD_PUT, |
1171 | GNUNET_REST_HANDLER_END | 1161 | GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, |
1172 | }; | 1162 | &ego_edit_subsystem}, |
1173 | 1163 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create}, | |
1174 | if (GNUNET_NO | 1164 | {MHD_HTTP_METHOD_DELETE, |
1175 | == GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, | 1165 | GNUNET_REST_API_NS_IDENTITY_PUBKEY, |
1176 | handle)) | 1166 | &ego_delete_pubkey}, |
1167 | {MHD_HTTP_METHOD_DELETE, | ||
1168 | GNUNET_REST_API_NS_IDENTITY_NAME, | ||
1169 | &ego_delete_name}, | ||
1170 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont}, | ||
1171 | GNUNET_REST_HANDLER_END}; | ||
1172 | |||
1173 | if (GNUNET_NO == | ||
1174 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | ||
1177 | { | 1175 | { |
1178 | handle->response_code = err.error_code; | 1176 | handle->response_code = err.error_code; |
1179 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1177 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
@@ -1214,8 +1212,10 @@ init_cont (struct RequestHandle *handle) | |||
1214 | * must thus no longer be used | 1212 | * must thus no longer be used |
1215 | */ | 1213 | */ |
1216 | static void | 1214 | static void |
1217 | init_egos (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | 1215 | init_egos (void *cls, |
1218 | const char *identifier) | 1216 | struct GNUNET_IDENTITY_Ego *ego, |
1217 | void **ctx, | ||
1218 | const char *identifier) | ||
1219 | { | 1219 | { |
1220 | struct RequestHandle *handle = cls; | 1220 | struct RequestHandle *handle = cls; |
1221 | struct EgoEntry *ego_entry; | 1221 | struct EgoEntry *ego_entry; |
@@ -1229,13 +1229,14 @@ init_egos (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
1229 | } | 1229 | } |
1230 | if (ID_REST_STATE_INIT == handle->state) | 1230 | if (ID_REST_STATE_INIT == handle->state) |
1231 | { | 1231 | { |
1232 | ego_entry = GNUNET_new(struct EgoEntry); | 1232 | ego_entry = GNUNET_new (struct EgoEntry); |
1233 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 1233 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); |
1234 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | 1234 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); |
1235 | ego_entry->ego = ego; | 1235 | ego_entry->ego = ego; |
1236 | GNUNET_asprintf (&ego_entry->identifier, "%s", identifier); | 1236 | GNUNET_asprintf (&ego_entry->identifier, "%s", identifier); |
1237 | GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head, handle->ego_tail, | 1237 | GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head, |
1238 | ego_entry); | 1238 | handle->ego_tail, |
1239 | ego_entry); | ||
1239 | } | 1240 | } |
1240 | } | 1241 | } |
1241 | 1242 | ||
@@ -1252,9 +1253,10 @@ init_egos (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | |||
1252 | */ | 1253 | */ |
1253 | static void | 1254 | static void |
1254 | rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | 1255 | rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, |
1255 | GNUNET_REST_ResultProcessor proc, void *proc_cls) | 1256 | GNUNET_REST_ResultProcessor proc, |
1257 | void *proc_cls) | ||
1256 | { | 1258 | { |
1257 | struct RequestHandle *handle = GNUNET_new(struct RequestHandle); | 1259 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); |
1258 | 1260 | ||
1259 | handle->response_code = 0; | 1261 | handle->response_code = 0; |
1260 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1262 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
@@ -1264,17 +1266,17 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1264 | handle->data = rest_handle->data; | 1266 | handle->data = rest_handle->data; |
1265 | handle->data_size = rest_handle->data_size; | 1267 | handle->data_size = rest_handle->data_size; |
1266 | 1268 | ||
1267 | handle->url = GNUNET_strdup(rest_handle->url); | 1269 | handle->url = GNUNET_strdup (rest_handle->url); |
1268 | if (handle->url[strlen (handle->url) - 1] == '/') | 1270 | if (handle->url[strlen (handle->url) - 1] == '/') |
1269 | handle->url[strlen (handle->url) - 1] = '\0'; | 1271 | handle->url[strlen (handle->url) - 1] = '\0'; |
1270 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | 1272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); |
1271 | 1273 | ||
1272 | handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &init_egos, handle); | 1274 | handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &init_egos, handle); |
1273 | 1275 | ||
1274 | handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout, | 1276 | handle->timeout_task = |
1275 | &do_error, handle); | 1277 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); |
1276 | 1278 | ||
1277 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | 1279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); |
1278 | } | 1280 | } |
1279 | 1281 | ||
1280 | /** | 1282 | /** |
@@ -1292,20 +1294,21 @@ libgnunet_plugin_rest_identity_init (void *cls) | |||
1292 | cfg = cls; | 1294 | cfg = cls; |
1293 | if (NULL != plugin.cfg) | 1295 | if (NULL != plugin.cfg) |
1294 | return NULL; /* can only initialize once! */ | 1296 | return NULL; /* can only initialize once! */ |
1295 | memset (&plugin, 0, sizeof(struct Plugin)); | 1297 | memset (&plugin, 0, sizeof (struct Plugin)); |
1296 | plugin.cfg = cfg; | 1298 | plugin.cfg = cfg; |
1297 | api = GNUNET_new(struct GNUNET_REST_Plugin); | 1299 | api = GNUNET_new (struct GNUNET_REST_Plugin); |
1298 | api->cls = &plugin; | 1300 | api->cls = &plugin; |
1299 | api->name = GNUNET_REST_API_NS_IDENTITY; | 1301 | api->name = GNUNET_REST_API_NS_IDENTITY; |
1300 | api->process_request = &rest_process_request; | 1302 | api->process_request = &rest_process_request; |
1301 | GNUNET_asprintf (&allow_methods, "%s, %s, %s, %s, %s", | 1303 | GNUNET_asprintf (&allow_methods, |
1302 | MHD_HTTP_METHOD_GET, | 1304 | "%s, %s, %s, %s, %s", |
1303 | MHD_HTTP_METHOD_POST, | 1305 | MHD_HTTP_METHOD_GET, |
1304 | MHD_HTTP_METHOD_PUT, | 1306 | MHD_HTTP_METHOD_POST, |
1305 | MHD_HTTP_METHOD_DELETE, | 1307 | MHD_HTTP_METHOD_PUT, |
1306 | MHD_HTTP_METHOD_OPTIONS); | 1308 | MHD_HTTP_METHOD_DELETE, |
1307 | 1309 | MHD_HTTP_METHOD_OPTIONS); | |
1308 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Identity REST API initialized\n")); | 1310 | |
1311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n")); | ||
1309 | return api; | 1312 | return api; |
1310 | } | 1313 | } |
1311 | 1314 | ||
@@ -1322,9 +1325,9 @@ libgnunet_plugin_rest_identity_done (void *cls) | |||
1322 | struct Plugin *plugin = api->cls; | 1325 | struct Plugin *plugin = api->cls; |
1323 | plugin->cfg = NULL; | 1326 | plugin->cfg = NULL; |
1324 | 1327 | ||
1325 | GNUNET_free_non_null(allow_methods); | 1328 | GNUNET_free_non_null (allow_methods); |
1326 | GNUNET_free(api); | 1329 | GNUNET_free (api); |
1327 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n"); | 1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n"); |
1328 | return NULL; | 1331 | return NULL; |
1329 | } | 1332 | } |
1330 | 1333 | ||