-static struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'e', "end", NULL, gettext_noop ("stop all GNUnet services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &end},
- {'i', "init", "SERVICE", gettext_noop ("start a particular service"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &init},
- {'k', "kill", "SERVICE", gettext_noop ("stop a particular service"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &term},
- {'s', "start", NULL, gettext_noop ("start all GNUnet default services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &start},
- {'r', "restart", NULL, gettext_noop ("stop and start all GNUnet default services"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &restart},
- {'t', "test", "SERVICE",
- gettext_noop ("test if a particular service is running"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &test},
- {'d', "delete", NULL, gettext_noop ("delete config file and directory on exit"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &delete},
- {'q', "quiet", NULL, gettext_noop ("don't print status messages"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet},
- GNUNET_GETOPT_OPTION_END
-};
+static void
+srv_status (void *cls,
+ const char *service,
+ enum GNUNET_ARM_ServiceStatus status)
+{
+ const char *msg;
+
+ (void) cls;
+ switch (status)
+ {
+ case GNUNET_ARM_SERVICE_MONITORING_STARTED:
+ return; /* this should be done silently */
+ case GNUNET_ARM_SERVICE_STOPPED:
+ msg = _("Stopped %s.\n");
+ break;
+ case GNUNET_ARM_SERVICE_STARTING:
+ msg = _("Starting %s...\n");
+ break;
+ case GNUNET_ARM_SERVICE_STOPPING:
+ msg = _("Stopping %s...\n");
+ break;
+ default:
+ msg = NULL;
+ break;
+ }
+ if (! quiet)
+ {
+ if (NULL != msg)
+ FPRINTF (stderr,
+ msg,
+ service);
+ else
+ FPRINTF (stderr,
+ _("Unknown status %u for service %s.\n"),
+ status,
+ service);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got service %s status %d\n",
+ service, (int)
+ status);
+}
+
+
+/**
+ * Task run on timeout (if -T is given).
+ */
+static void
+timeout_task_cb (void *cls)
+{
+ (void) cls;
+ timeout_task = NULL;
+ ret = 2;
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param c configuration
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
+{
+ (void) cls;
+ (void) args;
+ (void) cfgfile;
+ cfg = GNUNET_CONFIGURATION_dup (c);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "PATHS",
+ "GNUNET_HOME",
+ &dir))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "PATHS",
+ "GNUNET_HOME");
+ return;
+ }
+ (void) GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "arm",
+ "CONFIG",
+ &config_file);
+ if (NULL == (h = GNUNET_ARM_connect (cfg,
+ &conn_status,
+ NULL)))
+ return;
+ if (monitor)
+ m = GNUNET_ARM_monitor_start (cfg,
+ &srv_status,
+ NULL);
+ al_task = GNUNET_SCHEDULER_add_now (&action_loop,
+ NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
+ if (0 != timeout.rel_value_us)
+ timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
+ &timeout_task_cb,
+ NULL);
+}