GNUnet  0.10.x
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 
35 static void
36 cleanup_task (void *cls)
37 {
38  /* FIXME: do clean up here */
39 }
40 
41 
50 static void *
51 client_connect_cb (void *cls,
52  struct GNUNET_SERVICE_Client *c,
53  struct GNUNET_MQ_Handle *mq)
54 {
55  return c;
56 }
57 
58 
66 static void
68  struct GNUNET_SERVICE_Client *c,
69  void *internal_cls)
70 {
71  GNUNET_assert (c == internal_cls);
72 }
73 
74 
82 static void
83 run (void *cls,
84  const struct GNUNET_CONFIGURATION_Handle *cfg,
86 {
87  /* FIXME: do setup here */
89 }
90 
91 
95 GNUNET_SERVICE_MAIN ("template",
97  &run,
100  NULL,
102 
103 
104 /* end of gnunet-service-template.c */
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
Handle to a service.
Definition: service.c:116
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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 cleanup_task(void *cls)
Task run during shutdown.
Handle to a client that is connected to a service.
Definition: service.c:249
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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.
Handle to a message queue.
Definition: mq.c:85
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process template requests.
configuration data
Definition: configuration.c:85
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
Callback called when a client disconnected from the service.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.