GNUnet 0.21.1
gnunet-service-template.c File Reference

program that does template More...

#include "platform.h"
#include "gnunet_util_lib.h"
Include dependency graph for gnunet-service-template.c:

Go to the source code of this file.

Functions

static void cleanup_task (void *cls)
 Task run during shutdown. More...
 
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. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
 Callback called when a client disconnected from the service. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Process template requests. More...
 
 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. More...
 

Detailed Description

program that does template

Author
Christian Grothoff

Definition in file gnunet-service-template.c.

Function Documentation

◆ cleanup_task()

static void cleanup_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 36 of file gnunet-service-template.c.

37{
38 /* FIXME: do clean up here */
39}

Referenced by run().

Here is the caller graph for this function:

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
struct GNUNET_MQ_Handle mq 
)
static

Callback called when a client connects to the service.

Parameters
clsclosure for the service
cthe new client that connected to the service
mqthe message queue used to send messages to the client
Returns
c

Definition at line 51 of file gnunet-service-template.c.

54{
55 return c;
56}

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
void *  internal_cls 
)
static

Callback called when a client disconnected from the service.

Parameters
clsclosure for the service
cthe client that disconnected
internal_clsshould be equal to c

Definition at line 67 of file gnunet-service-template.c.

70{
71 GNUNET_assert (c == internal_cls);
72}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

References GNUNET_assert.

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Process template requests.

Parameters
clsclosure
cfgconfiguration to use
servicethe initialized service

Definition at line 83 of file gnunet-service-template.c.

86{
87 /* FIXME: do setup here */
89}
static void cleanup_task(void *cls)
Task run during shutdown.
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:1340

References cleanup_task(), and GNUNET_SCHEDULER_add_shutdown().

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

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.