aboutsummaryrefslogtreecommitdiff
path: root/src/template/gnunet-service-template.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-21 22:00:26 +0000
committerChristian Grothoff <christian@grothoff.org>2016-10-21 22:00:26 +0000
commita7e626e2a613e86f3ebf6ff6f8cfec1cc2a9758b (patch)
treebf5da6bc86d387ffbc885f20974385d581679993 /src/template/gnunet-service-template.c
parent51baa79fb2c3f05b79d012db22b8d47cdcacf976 (diff)
downloadgnunet-a7e626e2a613e86f3ebf6ff6f8cfec1cc2a9758b.tar.gz
gnunet-a7e626e2a613e86f3ebf6ff6f8cfec1cc2a9758b.zip
migrate template to new service API
Diffstat (limited to 'src/template/gnunet-service-template.c')
-rw-r--r--src/template/gnunet-service-template.c66
1 files changed, 46 insertions, 20 deletions
diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c
index 6ff63c073..815cc26d6 100644
--- a/src/template/gnunet-service-template.c
+++ b/src/template/gnunet-service-template.c
@@ -40,41 +40,67 @@ cleanup_task (void *cls)
40 40
41 41
42/** 42/**
43 * Callback called when a client connects to the service.
44 *
45 * @param cls closure for the service
46 * @param c the new client that connected to the service
47 * @param mq the message queue used to send messages to the client
48 * @return @a c
49 */
50static void *
51client_connect_cb (void *cls,
52 struct GNUNET_SERVICE_Client *c,
53 struct GNUNET_MQ_Handle *mq)
54{
55 return c;
56}
57
58
59/**
60 * Callback called when a client disconnected from the service
61 *
62 * @param cls closure for the service
63 * @param c the client that disconnected
64 * @param internal_cls should be equal to @a c
65 */
66static void
67client_disconnect_cb (void *cls,
68 struct GNUNET_SERVICE_Client *c,
69 void *internal_cls)
70{
71 GNUNET_assert (c == internal_cls);
72}
73
74
75/**
43 * Process template requests. 76 * Process template requests.
44 * 77 *
45 * @param cls closure 78 * @param cls closure
46 * @param server the initialized server
47 * @param cfg configuration to use 79 * @param cfg configuration to use
80 * @param service the initialized service
48 */ 81 */
49static void 82static void
50run (void *cls, 83run (void *cls,
51 struct GNUNET_SERVER_Handle *server, 84 const struct GNUNET_CONFIGURATION_Handle *cfg,
52 const struct GNUNET_CONFIGURATION_Handle *cfg) 85 struct GNUNET_SERVICE_Handle *service)
53{ 86{
54 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
55 /* FIXME: add handlers here! */
56 {NULL, NULL, 0, 0}
57 };
58 /* FIXME: do setup here */ 87 /* FIXME: do setup here */
59 GNUNET_SERVER_add_handlers (server, handlers);
60 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, 88 GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
61 NULL); 89 NULL);
62} 90}
63 91
64 92
65/** 93/**
66 * The main function for the template service. 94 * Define "main" method using service macro.
67 *
68 * @param argc number of arguments from the command line
69 * @param argv command line arguments
70 * @return 0 ok, 1 on error
71 */ 95 */
72int 96GNUNET_SERVICE_MAIN
73main (int argc, char *const *argv) 97("template",
74{ 98 GNUNET_SERVICE_OPTION_NONE,
75 return (GNUNET_OK == 99 &run,
76 GNUNET_SERVICE_run (argc, argv, "template", 100 &client_connect_cb,
77 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; 101 &client_disconnect_cb,
78} 102 NULL,
103 GNUNET_MQ_handler_end ());
104
79 105
80/* end of gnunet-service-template.c */ 106/* end of gnunet-service-template.c */