GNUnet  0.11.x
Data Structures | Functions
testing_api_cmd_hello_world.c File Reference

Command to start the netjail script. More...

#include "platform.h"
#include "gnunet_testing_ng_lib.h"
Include dependency graph for testing_api_cmd_hello_world.c:

Go to the source code of this file.

Data Structures

struct  HelloWorldState
 

Functions

static void hello_world_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 
static int hello_world_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 
static void hello_world_run (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
 Run the "hello world" CMD. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world (const char *label, const char *birthLabel, char *message)
 Create command. More...
 

Detailed Description

Command to start the netjail script.

implementation of a hello world command.

Command to stop the netjail script.

Command to start the netjail peers.

Author
t3sserakt

Definition in file testing_api_cmd_hello_world.c.

Function Documentation

◆ hello_world_cleanup()

static void hello_world_cleanup ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static
Parameters
clsclosure
cmdcurrent CMD being cleaned up.

Definition at line 42 of file testing_api_cmd_hello_world.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, and HelloWorldState::message.

Referenced by GNUNET_TESTING_cmd_hello_world().

44 {
45  struct HelloWorldState *hs = cls;
47  "Cleaning up message %s\n",
48  hs->message);
49 }
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ hello_world_traits()

static int hello_world_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static
Parameters
clsclosure.
[out]retresult
traitname of the trait.
indexindex number of the object to offer.
Returns
GNUNET_OK on success.

Definition at line 61 of file testing_api_cmd_hello_world.c.

References GNUNET_OK.

Referenced by GNUNET_TESTING_cmd_hello_world().

65 {
66  return GNUNET_OK;
67 }
Here is the caller graph for this function:

◆ hello_world_run()

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

Run the "hello world" CMD.

Parameters
clsclosure.
cmdCMD being run.
isinterpreter state.

Definition at line 77 of file testing_api_cmd_hello_world.c.

References HelloWorldState::birthLabel, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TESTING_get_trait_what_am_i(), GNUNET_TESTING_interpreter_lookup_command(), and HelloWorldState::message.

Referenced by GNUNET_TESTING_cmd_hello_world().

80 {
81  struct HelloWorldState *hs = cls;
82  const struct GNUNET_TESTING_Command *birth_cmd;
83 
85  "%s\n",
86  hs->message);
90  "Now I am a %s\n",
91  hs->message);
92 }
A command to be run by the interpreter.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(const char *label)
Lookup command by label.
int GNUNET_TESTING_get_trait_what_am_i(const struct GNUNET_TESTING_Command *cmd, char **what_am_i)
Offer data from trait.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_hello_world()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world ( const char *  label,
const char *  birthLabel,
char *  message 
)

Create command.

Parameters
labelname for command.
messageinitial message.
Returns
command.

Definition at line 102 of file testing_api_cmd_hello_world.c.

References HelloWorldState::birthLabel, GNUNET_TESTING_Command::cls, GNUNET_new, hello_world_cleanup(), hello_world_run(), hello_world_traits(), GNUNET_TESTING_Command::label, and HelloWorldState::message.

Referenced by start_testcase().

105 {
106  struct HelloWorldState *hs;
107 
108  hs = GNUNET_new (struct HelloWorldState);
109  hs->message = "Hello World, I was nobody!";
110  hs->birthLabel = birthLabel;
111 
112  struct GNUNET_TESTING_Command cmd = {
113  .cls = hs,
114  .label = label,
115  .run = &hello_world_run,
116  .cleanup = &hello_world_cleanup,
117  .traits = &hello_world_traits
118  };
119 
120  return cmd;
121 }
static void hello_world_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
const char * label
Label for the command.
A command to be run by the interpreter.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void hello_world_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
Run the "hello world" CMD.
static int hello_world_traits(void *cls, const void **ret, const char *trait, unsigned int index)
void * cls
Closure for all commands with command-specific context information.
Here is the call graph for this function:
Here is the caller graph for this function: