GNUnet  0.11.x
Functions
testing_api_traits.c File Reference

loop for trait resolution More...

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

Go to the source code of this file.

Functions

struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end ()
 End a trait array. More...
 
int 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_trait_end()

struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end ( void  )

End a trait array.

"end" trait.

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

Definition at line 37 of file testing_api_traits.c.

References end, and GNUNET_TESTING_Trait::index.

Referenced by batch_traits(), controller_traits(), hello_world_birth_traits(), and peer_traits().

38 {
39  struct GNUNET_TESTING_Trait end = {
40  .index = 0,
41  .trait_name = NULL,
42  .ptr = NULL
43  };
44 
45  return end;
46 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait()

int 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.

Extract a trait.

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 59 of file testing_api_traits.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_Trait::ptr, and GNUNET_TESTING_Trait::trait_name.

Referenced by batch_traits(), controller_traits(), hello_world_birth_traits(), and peer_traits().

63 {
64  for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
65  {
66  if ( (0 == strcmp (trait, traits[i].trait_name)) &&
67  (index == traits[i].index) )
68  {
69  *ret = (void *) traits[i].ptr;
70  return GNUNET_OK;
71  }
72  }
74  "Trait %s/%u not found.\n",
75  trait, index);
76 
77  return GNUNET_SYSERR;
78 }
const char * trait_name
Trait type, for example "reserve-pub" or "coin-priv".
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
const void * ptr
Pointer to the piece of data to offer.
unsigned int index
Index number associated with the trait.
#define GNUNET_log(kind,...)
Here is the caller graph for this function: