diff options
Diffstat (limited to 'src/statistics/gnunet-statistics.c')
-rw-r--r-- | src/statistics/gnunet-statistics.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 5267e38cf..80488958f 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -63,14 +63,11 @@ static int persistent; | |||
63 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 63 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
64 | */ | 64 | */ |
65 | static int | 65 | static int |
66 | printer (void *cls, | 66 | printer (void *cls, const char *subsystem, const char *name, uint64_t value, |
67 | const char *subsystem, | 67 | int is_persistent) |
68 | const char *name, uint64_t value, int is_persistent) | ||
69 | { | 68 | { |
70 | FPRINTF (stdout, | 69 | FPRINTF (stdout, "%s%-12s %-50s: %16llu\n", is_persistent ? "!" : " ", |
71 | "%s%-12s %-50s: %16llu\n", | 70 | subsystem, _(name), (unsigned long long) value); |
72 | is_persistent ? "!" : " ", subsystem, _(name), | ||
73 | (unsigned long long) value); | ||
74 | return GNUNET_OK; | 71 | return GNUNET_OK; |
75 | } | 72 | } |
76 | 73 | ||
@@ -106,17 +103,16 @@ cleanup (void *cls, int success) | |||
106 | * @param cfg configuration | 103 | * @param cfg configuration |
107 | */ | 104 | */ |
108 | static void | 105 | static void |
109 | run (void *cls, | 106 | run (void *cls, char *const *args, const char *cfgfile, |
110 | char *const *args, | 107 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
111 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
112 | { | 108 | { |
113 | struct GNUNET_STATISTICS_Handle *h; | 109 | struct GNUNET_STATISTICS_Handle *h; |
114 | unsigned long long val; | 110 | unsigned long long val; |
115 | 111 | ||
116 | if (args[0] != NULL) | 112 | if (args[0] != NULL) |
117 | { | 113 | { |
118 | if ((1 != SSCANF (args[0], "%llu", &val)) || | 114 | if ((1 != SSCANF (args[0], "%llu", &val)) || (subsystem == NULL) || |
119 | (subsystem == NULL) || (name == NULL)) | 115 | (name == NULL)) |
120 | { | 116 | { |
121 | FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]); | 117 | FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]); |
122 | ret = 1; | 118 | ret = 1; |
@@ -138,9 +134,9 @@ run (void *cls, | |||
138 | ret = 1; | 134 | ret = 1; |
139 | return; | 135 | return; |
140 | } | 136 | } |
141 | if (NULL == GNUNET_STATISTICS_get (h, | 137 | if (NULL == |
142 | subsystem, name, GET_TIMEOUT, &cleanup, | 138 | GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup, |
143 | &printer, h)) | 139 | &printer, h)) |
144 | cleanup (h, GNUNET_SYSERR); | 140 | cleanup (h, GNUNET_SYSERR); |
145 | } | 141 | } |
146 | 142 | ||
@@ -167,9 +163,7 @@ main (int argc, char *const *argv) | |||
167 | GNUNET_GETOPT_OPTION_END | 163 | GNUNET_GETOPT_OPTION_END |
168 | }; | 164 | }; |
169 | return (GNUNET_OK == | 165 | return (GNUNET_OK == |
170 | GNUNET_PROGRAM_run (argc, | 166 | GNUNET_PROGRAM_run (argc, argv, "gnunet-statistics [options [value]]", |
171 | argv, | ||
172 | "gnunet-statistics [options [value]]", | ||
173 | gettext_noop | 167 | gettext_noop |
174 | ("Print statistics about GNUnet operations."), | 168 | ("Print statistics about GNUnet operations."), |
175 | options, &run, NULL)) ? ret : 1; | 169 | options, &run, NULL)) ? ret : 1; |