GNUnet  0.11.x
Data Structures | Macros | Functions
testing_api_cmd_local_test_finished.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_cmd_local_test_finished.c:

Go to the source code of this file.

Data Structures

struct  LocalFinishedState
 Struct to hold information for callbacks. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 

Functions

static int local_test_finished_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 Trait function of this cmd does nothing. More...
 
static void local_test_finished_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static void local_test_finished_run (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
 This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop. More...
 
static int local_test_finished_finish (void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
 This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_finished (const char *label, TESTING_CMD_HELPER_write_cb write_message)
 Create command. More...
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 34 of file testing_api_cmd_local_test_finished.c.

Function Documentation

◆ local_test_finished_traits()

static int local_test_finished_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

Trait function of this cmd does nothing.

Definition at line 62 of file testing_api_cmd_local_test_finished.c.

66 {
67  return GNUNET_OK;
68 }
@ GNUNET_OK
Definition: gnunet_common.h:95

References GNUNET_OK.

◆ local_test_finished_cleanup()

static void local_test_finished_cleanup ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 76 of file testing_api_cmd_local_test_finished.c.

78 {
79  struct LocalFinishedState *lfs = cls;
80 
81  GNUNET_free (lfs->reply);
82  GNUNET_free (lfs);
83 }
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.
struct GNUNET_CMDS_LOCAL_FINISHED * reply
The message send back to the master loop.

References GNUNET_free, and LocalFinishedState::reply.

◆ local_test_finished_run()

static void local_test_finished_run ( void *  cls,
const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Interpreter is 
)
static

This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop.

Definition at line 91 of file testing_api_cmd_local_test_finished.c.

94 {
95  struct LocalFinishedState *lfs = cls;
96 
97  struct GNUNET_CMDS_LOCAL_FINISHED *reply;
98  size_t msg_length;
99 
100  msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
101  reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
103  reply->header.size = htons ((uint16_t) msg_length);
104  lfs->reply = reply;
105  lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
106 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
Definition: testing_cmds.h:85
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.

References GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED, GNUNET_new, GNUNET_CMDS_LOCAL_FINISHED::header, LocalFinishedState::reply, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and LocalFinishedState::write_message.

◆ local_test_finished_finish()

static int local_test_finished_finish ( void *  cls,
GNUNET_SCHEDULER_TaskCallback  cont,
void *  cont_cls 
)
static

This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method.

Definition at line 114 of file testing_api_cmd_local_test_finished.c.

117 {
119  "Stopping local loop\n");
120  return GNUNET_YES;
121 }
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_ERROR_TYPE_DEBUG
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, and LOG.

◆ GNUNET_TESTING_cmd_local_test_finished()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_finished ( const char *  label,
TESTING_CMD_HELPER_write_cb  write_message 
)

Create command.

Parameters
labelname for command.
write_messageCallback to write messages to the master loop.
Returns
command.

Definition at line 114 of file testing_api_cmd_local_test_finished.c.

135 {
136  struct LocalFinishedState *lfs;
137 
138  lfs = GNUNET_new (struct LocalFinishedState);
140 
141  struct GNUNET_TESTING_Command cmd = {
142  .cls = lfs,
143  .label = label,
144  .run = &local_test_finished_run,
145  .finish = &local_test_finished_finish,
146  .cleanup = &local_test_finished_cleanup,
147  .traits = &local_test_finished_traits
148  };
149 
150  return cmd;
151 }
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
A command to be run by the interpreter.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
static int local_test_finished_finish(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
This finish function will stop the local loop without shutting down the scheduler,...
static int local_test_finished_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static void local_test_finished_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static void local_test_finished_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop.