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