GNUnet 0.21.1
testing_api_traits.c File Reference

loop for trait resolution More...

#include "platform.h"
#include "gnunet_testing_lib.h"
Include dependency graph for testing_api_traits.c:

Go to the source code of this file.

Functions

 GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT, GNUNET_TESTING)
 End a trait array. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
 Pick the chosen trait from the traits array. More...
 

Detailed Description

loop for trait resolution

Author
Christian Grothoff (GNU Taler testing)
Marcello Stanisci (GNU Taler testing)
t3sserakt

Definition in file testing_api_traits.c.

Function Documentation

◆ GNUNET_TESTING_SIMPLE_TRAITS()

GNUNET_TESTING_SIMPLE_TRAITS ( GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT  ,
GNUNET_TESTING   
)

End a trait array.

Usually, commands offer several traits, and put them in arrays.

Definition at line 32 of file testing_api_traits.c.

41{
42 struct GNUNET_TESTING_Trait end = {
43 .index = 0,
44 .trait_name = NULL,
45 .ptr = NULL
46 };
47
48 return end;
49}
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.

References end.

◆ GNUNET_TESTING_get_trait()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait ( const struct GNUNET_TESTING_Trait traits,
const void **  ret,
const char *  trait,
unsigned int  index 
)

Pick the chosen trait from the traits array.

Obtain value of a trait from a command.

Parameters
traitsthe traits array.
retwhere to store the result.
traittype of the trait to extract.
indexindex number of the object to extract.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 62 of file testing_api_traits.c.

66{
67 for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
68 {
69 if ( (0 == strcmp (trait, traits[i].trait_name)) &&
70 (index == traits[i].index) )
71 {
72 *ret = (void *) traits[i].ptr;
73 return GNUNET_OK;
74 }
75 }
77 "Trait %s/%u not found.\n",
78 trait, index);
79
80 return GNUNET_SYSERR;
81}
static int ret
Final status code.
Definition: gnunet-arm.c:94
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_INFO
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_Trait::index, GNUNET_TESTING_Trait::ptr, ret, GNUNET_TESTING_Trait::trait_name, and traits().

Referenced by barrier_reached_traits(), barrier_traits(), batch_traits(), connect_peers_traits(), netjail_exec_traits(), start_peer_traits(), start_service_traits(), stop_peer_traits(), system_create_traits(), and traits().

Here is the call graph for this function:
Here is the caller graph for this function: