*/
static struct StatsEntry *start;
-/**
- * Counter used to generate unique values.
- */
-static uint32_t uidgen;
-
/**
* Load persistent values from disk. Disk format is
* exactly the same format that we also use for
const struct StatsEntry *e)
{
struct GNUNET_STATISTICS_ReplyMessage *m;
- struct GNUNET_MessageHeader *h;
size_t size;
- uint16_t msize;
size =
sizeof (struct GNUNET_STATISTICS_ReplyMessage) + strlen (e->service) + 1 +
strlen (e->name) + 1;
GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- msize = size - sizeof (struct GNUNET_MessageHeader);
m = GNUNET_malloc (size);
+ m->header.type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_VALUE);
+ m->header.size = htons (size);
m->uid = htonl (e->uid);
if (e->persistent)
m->uid |= htonl (GNUNET_STATISTICS_PERSIST_BIT);
"Transmitting value for `%s:%s': %llu\n",
e->service, e->name, e->value);
#endif
- h = &m->header;
- GNUNET_SERVER_transmit_context_append (tc,
- &h[1],
- msize,
- GNUNET_MESSAGE_TYPE_STATISTICS_VALUE);
+ GNUNET_SERVER_transmit_context_append_message (tc, &m->header);
GNUNET_free (m);
}
transmit (tc, pos);
pos = pos->next;
}
- GNUNET_SERVER_transmit_context_append (tc, NULL, 0,
- GNUNET_MESSAGE_TYPE_STATISTICS_END);
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+ GNUNET_MESSAGE_TYPE_STATISTICS_END);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
}
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
+ /**
+ * Counter used to generate unique values.
+ */
+ static uint32_t uidgen;
+
char *service;
char *name;
uint16_t msize;
}
-/**
- * List of handlers for the messages understood by this
- * service.
- */
-static struct GNUNET_SERVER_MessageHandler handlers[] = {
- {&handle_set, NULL, GNUNET_MESSAGE_TYPE_STATISTICS_SET, 0},
- {&handle_get, NULL, GNUNET_MESSAGE_TYPE_STATISTICS_GET, 0},
- {NULL, NULL, 0, 0}
-};
-
-
/**
* Task run during shutdown.
*
struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
+ static const struct GNUNET_SERVER_MessageHandler handlers[] = {
+ {&handle_set, NULL, GNUNET_MESSAGE_TYPE_STATISTICS_SET, 0},
+ {&handle_get, NULL, GNUNET_MESSAGE_TYPE_STATISTICS_GET, 0},
+ {NULL, NULL, 0, 0}
+ };
cfg = c;
GNUNET_SERVER_add_handlers (server, handlers);
load (server);
return (GNUNET_OK ==
GNUNET_SERVICE_run (argc,
argv,
- "statistics", &run, NULL)) ? 0 : 1;
+ "statistics",
+ GNUNET_SERVICE_OPTION_NONE,
+ &run, NULL)) ? 0 : 1;
}
/* end of gnunet-service-statistics.c */