GNUnet 0.21.1
gnunet-service-template.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_util_lib.h"
28
29
35static void
36cleanup_task (void *cls)
37{
38 /* FIXME: do clean up here */
39}
40
41
50static void *
52 struct GNUNET_SERVICE_Client *c,
53 struct GNUNET_MQ_Handle *mq)
54{
55 return c;
56}
57
58
66static void
68 struct GNUNET_SERVICE_Client *c,
69 void *internal_cls)
70{
71 GNUNET_assert (c == internal_cls);
72}
73
74
82static void
83run (void *cls,
84 const struct GNUNET_CONFIGURATION_Handle *cfg,
86{
87 /* FIXME: do setup here */
89}
90
91
97 &run,
100 NULL,
102
103
104/* end of gnunet-service-template.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
GNUNET_SERVICE_MAIN("template", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void cleanup_task(void *cls)
Task run during shutdown.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
Callback called when a client disconnected from the service.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process template requests.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1334
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
Handle to a message queue.
Definition: mq.c:87
Handle to a client that is connected to a service.
Definition: service.c:252
Handle to a service.
Definition: service.c:118