diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-29 20:47:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-29 20:47:18 +0000 |
commit | 71ea5bd2d05058008e604ffd42993be9c7250e04 (patch) | |
tree | a5074671ddfaa9d1621a4182fc95a91a98b3d536 /src/transport/transport-testing.c | |
parent | b335777fd435142c16eb05e86c8a64a4b1a45447 (diff) | |
download | gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.tar.gz gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.zip |
-fixing indentation
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r-- | src/transport/transport-testing.c | 90 |
1 files changed, 44 insertions, 46 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index e45953239..9f7a99a7b 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -284,22 +284,22 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
284 | p->cfg = GNUNET_CONFIGURATION_create (); | 284 | p->cfg = GNUNET_CONFIGURATION_create (); |
285 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 285 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
286 | 286 | ||
287 | if (GNUNET_CONFIGURATION_have_value (p-> | 287 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) |
288 | cfg, "PATHS", "SERVICEHOME")) | ||
289 | GNUNET_assert (GNUNET_OK == | 288 | GNUNET_assert (GNUNET_OK == |
290 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", | 289 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", |
291 | "SERVICEHOME", | 290 | "SERVICEHOME", |
292 | &p->servicehome)); | 291 | &p->servicehome)); |
293 | 292 | ||
294 | if (NULL != p->servicehome) | 293 | if (NULL != p->servicehome) |
295 | GNUNET_DISK_directory_remove (p->servicehome); | 294 | GNUNET_DISK_directory_remove (p->servicehome); |
296 | 295 | ||
297 | hostkey = get_host_key(tth); | 296 | hostkey = get_host_key (tth); |
298 | if (hostkey != NULL) | 297 | if (hostkey != NULL) |
299 | { | 298 | { |
300 | 299 | ||
301 | GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome); | 300 | GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome); |
302 | GNUNET_assert(GNUNET_OK == GNUNET_DISK_directory_create_for_file (p->hostkeyfile)); | 301 | GNUNET_assert (GNUNET_OK == |
302 | GNUNET_DISK_directory_create_for_file (p->hostkeyfile)); | ||
303 | fn = GNUNET_DISK_file_open (p->hostkeyfile, | 303 | fn = GNUNET_DISK_file_open (p->hostkeyfile, |
304 | GNUNET_DISK_OPEN_READWRITE | | 304 | GNUNET_DISK_OPEN_READWRITE | |
305 | GNUNET_DISK_OPEN_CREATE, | 305 | GNUNET_DISK_OPEN_CREATE, |
@@ -355,11 +355,11 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
355 | * @return GNUNET_OK in success otherwise GNUNET_SYSERR | 355 | * @return GNUNET_OK in success otherwise GNUNET_SYSERR |
356 | */ | 356 | */ |
357 | int | 357 | int |
358 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 358 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle |
359 | struct PeerContext *p, | 359 | *tth, struct PeerContext *p, |
360 | const char *cfgname, | 360 | const char *cfgname, |
361 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, | 361 | GNUNET_TRANSPORT_TESTING_start_cb |
362 | void *cb_cls) | 362 | restart_cb, void *cb_cls) |
363 | { | 363 | { |
364 | struct GNUNET_DISK_FileHandle *fn; | 364 | struct GNUNET_DISK_FileHandle *fn; |
365 | 365 | ||
@@ -370,9 +370,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t | |||
370 | 370 | ||
371 | /* shutdown */ | 371 | /* shutdown */ |
372 | #if VERBOSE | 372 | #if VERBOSE |
373 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 373 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
374 | "Stopping peer %u (`%s')\n", p->no, | 374 | "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); |
375 | GNUNET_i2s (&p->id)); | ||
376 | #endif | 375 | #endif |
377 | if (p->ghh != NULL) | 376 | if (p->ghh != NULL) |
378 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 377 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
@@ -400,48 +399,48 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t | |||
400 | 399 | ||
401 | /* start */ | 400 | /* start */ |
402 | #if VERBOSE | 401 | #if VERBOSE |
403 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 402 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
404 | "Restarting peer %u (`%s')\n", p->no, | 403 | "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); |
405 | GNUNET_i2s (&p->id)); | ||
406 | #endif | 404 | #endif |
407 | 405 | ||
408 | sleep (5); // YUCK! | 406 | sleep (5); // YUCK! |
409 | 407 | ||
410 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) | 408 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) |
411 | { | 409 | { |
412 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 410 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", |
413 | "File not found: `%s' \n", cfgname); | 411 | "File not found: `%s' \n", cfgname); |
414 | goto fail; | 412 | goto fail; |
415 | } | 413 | } |
416 | 414 | ||
417 | p->cfg = GNUNET_CONFIGURATION_create (); | 415 | p->cfg = GNUNET_CONFIGURATION_create (); |
418 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 416 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
419 | 417 | ||
420 | if (! GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) | 418 | if (!GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) |
421 | goto fail; | 419 | goto fail; |
422 | 420 | ||
423 | fn = GNUNET_DISK_file_open (p->hostkeyfile, | 421 | fn = GNUNET_DISK_file_open (p->hostkeyfile, |
424 | GNUNET_DISK_OPEN_READWRITE | | 422 | GNUNET_DISK_OPEN_READWRITE | |
425 | GNUNET_DISK_OPEN_CREATE, | 423 | GNUNET_DISK_OPEN_CREATE, |
426 | GNUNET_DISK_PERM_USER_READ | | 424 | GNUNET_DISK_PERM_USER_READ | |
427 | GNUNET_DISK_PERM_USER_WRITE); | 425 | GNUNET_DISK_PERM_USER_WRITE); |
428 | if (fn == NULL) | 426 | if (fn == NULL) |
429 | goto fail; | 427 | goto fail; |
430 | if (GNUNET_OK != GNUNET_DISK_file_close (fn)) | 428 | if (GNUNET_OK != GNUNET_DISK_file_close (fn)) |
431 | goto fail; | 429 | goto fail; |
432 | 430 | ||
433 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 431 | p->arm_proc = |
434 | "gnunet-service-arm", "-c", cfgname, | 432 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
435 | #if VERBOSE_PEERS | 433 | "gnunet-service-arm", "-c", cfgname, |
436 | "-L", "DEBUG", | 434 | #if VERBOSE_PEERS |
437 | #else | 435 | "-L", "DEBUG", |
438 | "-L", "ERROR", | 436 | #else |
439 | #endif | 437 | "-L", "ERROR", |
440 | NULL); | 438 | #endif |
439 | NULL); | ||
441 | 440 | ||
442 | p->th = | 441 | p->th = |
443 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, | 442 | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, |
444 | ¬ify_connect, ¬ify_disconnect); | 443 | ¬ify_connect, ¬ify_disconnect); |
445 | GNUNET_assert (p->th != NULL); | 444 | GNUNET_assert (p->th != NULL); |
446 | 445 | ||
447 | p->start_cb = restart_cb; | 446 | p->start_cb = restart_cb; |
@@ -451,11 +450,11 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t | |||
451 | GNUNET_assert (p->ghh != NULL); | 450 | GNUNET_assert (p->ghh != NULL); |
452 | return GNUNET_OK; | 451 | return GNUNET_OK; |
453 | 452 | ||
454 | fail: | 453 | fail: |
455 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 454 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
456 | "Restarting peer %u (`%s') failed, removing peer\n", p->no, | 455 | "Restarting peer %u (`%s') failed, removing peer\n", p->no, |
457 | GNUNET_i2s (&p->id)); | 456 | GNUNET_i2s (&p->id)); |
458 | GNUNET_TRANSPORT_TESTING_stop_peer (tth,p); | 457 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
459 | return GNUNET_SYSERR; | 458 | return GNUNET_SYSERR; |
460 | } | 459 | } |
461 | 460 | ||
@@ -643,11 +642,11 @@ GNUNET_TRANSPORT_TESTING_init () | |||
643 | /* prepare hostkeys */ | 642 | /* prepare hostkeys */ |
644 | tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); | 643 | tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); |
645 | tth->hostkey_data = NULL; | 644 | tth->hostkey_data = NULL; |
646 | const char * hostkeys_file = "../../contrib/testing_hostkeys.dat"; | 645 | const char *hostkeys_file = "../../contrib/testing_hostkeys.dat"; |
646 | |||
647 | if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) | 647 | if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) |
648 | { | 648 | { |
649 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 649 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not read hostkeys file!\n")); |
650 | _("Could not read hostkeys file!\n")); | ||
651 | } | 650 | } |
652 | else | 651 | else |
653 | { | 652 | { |
@@ -656,8 +655,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
656 | GNUNET_DISK_PERM_NONE); | 655 | GNUNET_DISK_PERM_NONE); |
657 | if (NULL == fd) | 656 | if (NULL == fd) |
658 | { | 657 | { |
659 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", | 658 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file); |
660 | hostkeys_file); | ||
661 | GNUNET_free (tth); | 659 | GNUNET_free (tth); |
662 | return NULL; | 660 | return NULL; |
663 | } | 661 | } |
@@ -668,7 +666,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
668 | if (0 != (fs % HOSTKEYFILESIZE)) | 666 | if (0 != (fs % HOSTKEYFILESIZE)) |
669 | { | 667 | { |
670 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 668 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", |
671 | "File size %llu seems incorrect for hostkeys...\n", fs); | 669 | "File size %llu seems incorrect for hostkeys...\n", fs); |
672 | } | 670 | } |
673 | else | 671 | else |
674 | { | 672 | { |
@@ -676,7 +674,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
676 | tth->hostkey_data = GNUNET_malloc_large (fs); | 674 | tth->hostkey_data = GNUNET_malloc_large (fs); |
677 | GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs)); | 675 | GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs)); |
678 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 676 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
679 | "Read %llu hostkeys from file\n", total_hostkeys); | 677 | "Read %llu hostkeys from file\n", total_hostkeys); |
680 | tth->hostkeys_total = total_hostkeys; | 678 | tth->hostkeys_total = total_hostkeys; |
681 | } | 679 | } |
682 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); | 680 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); |