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

implementation of a hello world command. 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)
 
static enum GNUNET_GenericReturnValue hello_world_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 
static void hello_world_run (void *cls, 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

implementation of a hello world command.

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)
static
Parameters
clsclosure

Definition at line 42 of file testing_api_cmd_hello_world.c.

43 {
44  struct HelloWorldState *hs = cls;
45 
47  "Cleaning up message %s\n",
48  hs->message);
49  GNUNET_free (hs);
50 }
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, and HelloWorldState::message.

◆ hello_world_traits()

static enum GNUNET_GenericReturnValue 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 42 of file testing_api_cmd_hello_world.c.

67 {
68  return GNUNET_NO;
69 }
@ GNUNET_NO
Definition: gnunet_common.h:94

◆ hello_world_run()

static void hello_world_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

Run the "hello world" CMD.

Parameters
clsclosure.
isinterpreter state.

Definition at line 79 of file testing_api_cmd_hello_world.c.

81 {
82  struct HelloWorldState *hs = cls;
83  const struct GNUNET_TESTING_Command *birth_cmd;
84 
86  "%s\n",
87  hs->message);
89  hs->birthLabel);
91  &hs->message);
93  "Now I am a %s\n",
94  hs->message);
95 }
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, 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.
A command to be run by the interpreter.

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

Here is the call 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 79 of file testing_api_cmd_hello_world.c.

109 {
110  struct HelloWorldState *hs;
111 
112  hs = GNUNET_new (struct HelloWorldState);
113  hs->message = "Hello World, I was nobody!";
114  hs->birthLabel = birthLabel;
115  {
116  struct GNUNET_TESTING_Command cmd = {
117  .cls = hs,
118  .label = label,
119  .run = &hello_world_run,
120  .cleanup = &hello_world_cleanup,
121  .traits = &hello_world_traits
122  };
123 
124  return cmd;
125  }
126 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
static enum GNUNET_GenericReturnValue hello_world_traits(void *cls, const void **ret, const char *trait, unsigned int index)
static void hello_world_cleanup(void *cls)
static void hello_world_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the "hello world" CMD.