*/
static int persistent;
+/**
+ * Watch value continuously
+ */
+static int watch;
+
/**
* Quiet mode
*/
if (h != NULL)
GNUNET_STATISTICS_destroy (h, GNUNET_NO);
}
-
+static void
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_STATISTICS_Handle *h = cls;
+ GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h);
+ if (h != NULL)
+ GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+}
/**
* Main function that will be run by the scheduler.
ret = 1;
return;
}
- if (NULL ==
+ if (GNUNET_NO == watch)
+ {
+ if (NULL ==
GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup,
&printer, h))
cleanup (h, GNUNET_SYSERR);
+ }
+ else
+ {
+ if ((NULL == subsystem) || (NULL == name))
+ {
+ printf (_("No subsystem or name given\n"));
+ if (h != NULL)
+ GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+ ret = 1;
+ return;
+ }
+ GNUNET_STATISTICS_watch(h, subsystem, name, &printer, h);
+ GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, h);
+ }
}
/**
{'q', "quiet", NULL,
gettext_noop ("just print the statistics value"), 0,
&GNUNET_GETOPT_set_one, &quiet},
+ {'w', "watch", NULL,
+ gettext_noop ("watch value continously"), 0,
+ &GNUNET_GETOPT_set_one, &watch},
GNUNET_GETOPT_OPTION_END
};
return (GNUNET_OK ==