aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-24 14:47:09 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-24 14:47:09 +0000
commitf82ac0f3dd7f6da49cef39afee98ef5a9ec36b3f (patch)
treebe2f02bbce47fdcc2ceb5c0adf61bb582c710d79 /src/peerinfo-tool
parent6611fb5b440f760258c9d348dfa36144ca854cde (diff)
downloadgnunet-f82ac0f3dd7f6da49cef39afee98ef5a9ec36b3f.tar.gz
gnunet-f82ac0f3dd7f6da49cef39afee98ef5a9ec36b3f.zip
added check if service is running
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index eb69a0804..ba2480c20 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -615,37 +615,25 @@ shutdown_task (void *cls,
615 } 615 }
616} 616}
617 617
618
619/** 618/**
620 * Main function that will be run by the scheduler. 619 * Function called with the result of the check if the 'peerinfo'
620 * service is running.
621 * 621 *
622 * @param cls closure 622 * @param cls closure with our configuration
623 * @param args remaining command-line arguments 623 * @param result #GNUNET_YES if transport is running
624 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
625 * @param c configuration
626 */ 624 */
627static void 625static void
628run (void *cls, char *const *args, const char *cfgfile, 626testservice_task (void *cls, int result)
629 const struct GNUNET_CONFIGURATION_Handle *c)
630{ 627{
631 struct GNUNET_CRYPTO_EddsaPrivateKey *priv; 628 struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
632 char *fn; 629 char *fn;
633 630
634 cfg = c; 631 if (GNUNET_YES != result)
635 if ( (NULL != args[0]) &&
636 (NULL == put_uri) &&
637 (args[0] == strcasestr (args[0], "gnunet://hello/")) )
638 {
639 put_uri = GNUNET_strdup (args[0]);
640 args++;
641 }
642 if (NULL != args[0])
643 { 632 {
644 FPRINTF (stderr, 633 FPRINTF (stderr, _("Service `%s' is not running, please start GNUnet\n"), "peerinfo");
645 _("Invalid command line argument `%s'\n"),
646 args[0]);
647 return; 634 return;
648 } 635 }
636
649 if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) 637 if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg)))
650 { 638 {
651 FPRINTF (stderr, "%s", _("Could not access PEERINFO service. Exiting.\n")); 639 FPRINTF (stderr, "%s", _("Could not access PEERINFO service. Exiting.\n"));
@@ -675,8 +663,41 @@ run (void *cls, char *const *args, const char *cfgfile,
675 663
676 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); 664 tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
677 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 665 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
678 &shutdown_task, 666 &shutdown_task,
679 NULL); 667 NULL);
668}
669
670
671/**
672 * Main function that will be run by the scheduler.
673 *
674 * @param cls closure
675 * @param args remaining command-line arguments
676 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
677 * @param c configuration
678 */
679static void
680run (void *cls, char *const *args, const char *cfgfile,
681 const struct GNUNET_CONFIGURATION_Handle *c)
682{
683 cfg = c;
684 if ( (NULL != args[0]) &&
685 (NULL == put_uri) &&
686 (args[0] == strcasestr (args[0], "gnunet://hello/")) )
687 {
688 put_uri = GNUNET_strdup (args[0]);
689 args++;
690 }
691 if (NULL != args[0])
692 {
693 FPRINTF (stderr,
694 _("Invalid command line argument `%s'\n"),
695 args[0]);
696 return;
697 }
698
699 GNUNET_CLIENT_service_test ("peerinfo", cfg, GNUNET_TIME_UNIT_SECONDS,
700 &testservice_task, (void *) cfg);
680} 701}
681 702
682 703