35 #ifndef GNUNET_MY_LIB_H
36 #define GNUNET_MY_LIB_H
41 #include <mysql/mysql.h>
44 #error "You need to define MYSQL_BOOL. See (or include) gnunet_mysql_compat.h"
130 #define GNUNET_MY_query_param_end { NULL, NULL, NULL, 0, NULL, 0 }
163 struct GNUNET_MY_ResultParam;
266 #define GNUNET_MY_result_spec_end { NULL, NULL, NULL, 0, NULL, 0, 0 }
294 #define GNUNET_MY_query_param_auto_from_type( \
295 x) GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x)))
371 #define GNUNET_MY_result_spec_auto_from_type( \
372 dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst)))
static struct SolverHandle * sh
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static unsigned int results
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time in network byte order expected.
void(* GNUNET_MY_QueryCleanup)(void *cls, MYSQL_BIND *qbind)
Function called to cleanup result data.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint16(uint16_t *u16)
uint16_t expected
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at)
Absolute time expected.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x)
Generate query parameter for an absolute time value.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_variable_size(void **dst, size_t *ptr_size)
Variable-size result expected.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_string(char **dst)
0- terminated string exprected.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x)
Generate query parameter for an absolute time value.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig)
RSA signature expected.
void GNUNET_MY_cleanup_query(struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Free all memory that was allocated in qp during #GNUNET_MY_exect_prepared().
int(* GNUNET_MY_QueryConverter)(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint64(const uint64_t *x)
Generate query parameter for an uint64_t in host byte order.
void GNUNET_MY_cleanup_result(struct GNUNET_MY_ResultSpec *rs)
Free all memory that was allocated in rs during GNUNET_MY_extract_result().
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_string(const char *ptr)
Generate query parameter for a string.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa)
RSA public key expected.
void(* GNUNET_MY_ResultCleanup)(void *cls, struct GNUNET_MY_ResultSpec *rs)
Function called to cleanup result data.
int(* GNUNET_MY_ResultConverter)(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Function called to convert input argument into SQL parameters.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_fixed_size(void *ptr, size_t ptr_size)
Obtain fixed size result of ptr_size bytes from MySQL, store in already allocated buffer at ptr.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_fixed_size(const void *ptr, size_t ptr_size)
Generate query parameter for a buffer ptr of ptr_size bytes.FG.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint16(const uint16_t *x)
Generate query parameter for an uint16_t in host byte order.
int GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, struct GNUNET_MYSQL_StatementHandle *sh, struct GNUNET_MY_QueryParam *params)
Run a prepared SELECT statement.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint32(const uint32_t *x)
Generate query parameter for an uint32_t in host byte order.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint32(uint32_t *u32)
uint32_t expected
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x)
Generate query parameter for an RSA signature.
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint64(uint64_t *u64)
uint64_t expected.
int GNUNET_MY_extract_result(struct GNUNET_MYSQL_StatementHandle *sh, struct GNUNET_MY_ResultSpec *specs)
Extract results from a query result according to the given specification.
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x)
Generate query parameter for an RSA public key.
The public information of an RSA key pair.
Handle for a prepared statement.
Information we pass to GNUNET_MY_exec_prepared() to initialize the arguments of the prepared statemen...
unsigned long data_len
Information to pass to conv.
const void * data
Information to pass to conv.
void * conv_cls
Closure for conv.
unsigned int num_params
Number of arguments the conv converter expects to initialize.
GNUNET_MY_QueryCleanup cleaner
Function to call for cleaning up the query.
GNUNET_MY_QueryConverter conv
Function to call for the type conversion.
Information we pass to GNUNET_MY_extract_result() to initialize the arguments of the prepared stateme...
void * conv_cls
Closure for conv.
GNUNET_MY_ResultConverter post_conv
Function to call for converting the result.
size_t dst_size
Allowed size for the data, 0 for variable-size (in this case, the type of dst is a void ** and we nee...
MYSQL_BOOL is_null
Memory for MySQL to notify us about NULL values.
unsigned int num_fields
How many fields does this result specification occupy in the result returned by MySQL.
void * dst
Destination for the data.
size_t * result_size
Where to store actual size of the result.
GNUNET_MY_ResultConverter pre_conv
Function to call to initialize the MYSQL_BIND array.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
GNUNET_MY_ResultCleanup cleaner
Function to call for cleaning up the result.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.