+
+/**
+ * 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 cfg configuration
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ struct GNUNET_CONFIGURATION_Handle *c;
+
+ c = (struct GNUNET_CONFIGURATION_Handle *) cfg;
+ set_value = GNUNET_NO;
+ if (NULL != args[0])
+ {
+ if (1 != SSCANF (args[0],
+ "%llu",
+ &set_val))
+ {
+ FPRINTF (stderr,
+ _("Invalid argument `%s'\n"),
+ args[0]);
+ ret = 1;
+ return;
+ }
+ set_value = GNUNET_YES;
+ }
+ if (NULL != remote_host)
+ {
+ if (0 == remote_port)
+ {
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "statistics",
+ "PORT",
+ &remote_port))
+ {
+ FPRINTF (stderr,
+ _("A port is required to connect to host `%s'\n"),
+ remote_host);
+ return;
+ }
+ }
+ else if (65535 <= remote_port)
+ {
+ FPRINTF (stderr,
+ _("A port has to be between 1 and 65535 to connect to host `%s'\n"),
+ remote_host);
+ return;
+ }
+
+ /* Manipulate configuration */
+ GNUNET_CONFIGURATION_set_value_string (c,
+ "statistics",
+ "UNIXPATH",
+ "");
+ GNUNET_CONFIGURATION_set_value_string (c,
+ "statistics",
+ "HOSTNAME",
+ remote_host);
+ GNUNET_CONFIGURATION_set_value_number (c,
+ "statistics",
+ "PORT",
+ remote_port);
+ }
+ GNUNET_SCHEDULER_add_now (&main_task,
+ c);
+}
+
+