GNUnet  0.10.x
Functions
my_result_helper.c File Reference

functions to extract result values More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_my_lib.h"
Include dependency graph for my_result_helper.c:

Go to the source code of this file.

Functions

static int pre_extract_varsize_blob (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 extract data from a Mysql database result at row row More...
 
static int post_extract_varsize_blob (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 extract data from a Mysql database result at row row More...
 
static void cleanup_varsize_blob (void *cls, struct GNUNET_MY_ResultSpec *rs)
 extract data from a Mysql database result at row row More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_variable_size (void **dst, size_t *ptr_size)
 Variable-size result expected. More...
 
static int pre_extract_fixed_blob (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Mysql database result at row row. More...
 
static int post_extract_fixed_blob (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Check size of extracted fixed size data from a Mysql database result at row row. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_fixed_size (void *ptr, size_t ptr_size)
 Fixed-size result expected. More...
 
static int pre_extract_rsa_public_key (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Mysql database result at row row. More...
 
static int post_extract_rsa_public_key (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Check size of extracted fixed size data from a Mysql database result at row row. More...
 
static void clean_rsa_public_key (void *cls, struct GNUNET_MY_ResultSpec *rs)
 Function called to clean up memory allocated by a GNUNET_MY_ResultConverter. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa)
 RSA public key expected. More...
 
static int pre_extract_rsa_signature (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Mysql database result at row row. More...
 
static int post_extract_rsa_signature (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Mysql database result at row row. More...
 
static void clean_rsa_signature (void *cls, struct GNUNET_MY_ResultSpec *rs)
 Function called to clean up memory allocated by a GNUNET_MY_ResultConverter. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig)
 RSA signature expected. More...
 
static int pre_extract_string (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Mysql database result at row row. More...
 
static int post_extract_string (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Check size of extracted fixed size data from a Mysql database . More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_string (char **dst)
 0- terminated string exprected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at)
 Absolute time expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at)
 Absolute time in network byte order expected. More...
 
static int pre_extract_uint16 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a Postgres database result at row row. More...
 
static int post_extract_uint16 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Check size of extracted fixed size data from a Mysql datbase. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint16 (uint16_t *u16)
 uint16_t expected More...
 
static int pre_extract_uint32 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extrac data from a MYSQL database result at row row. More...
 
static int post_extract_uint32 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extrac data from a MYSQL database result at row row. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint32 (uint32_t *u32)
 uint32_t expected More...
 
static int pre_extract_uint64 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Extract data from a MYSQL database result at row row. More...
 
static int post_extract_uint64 (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Check size of extracted fixe size data from a Mysql database. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint64 (uint64_t *u64)
 uint64_t expected. More...
 

Detailed Description

functions to extract result values

Author
Christophe Genevey

Definition in file my_result_helper.c.

Function Documentation

◆ pre_extract_varsize_blob()

static int pre_extract_varsize_blob ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

extract data from a Mysql database result at row row

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]resultmysql result
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid

Definition at line 44 of file my_result_helper.c.

References GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_variable_size().

49 {
50  results[0].buffer = NULL;
51  results[0].buffer_length = 0;
52  results[0].length = &rs->mysql_bind_output_length;
53  results[0].is_null = &rs->is_null;
54  rs->is_null = 0;
55 
56  return GNUNET_OK;
57 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
Here is the caller graph for this function:

◆ post_extract_varsize_blob()

static int post_extract_varsize_blob ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

extract data from a Mysql database result at row row

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid

Definition at line 73 of file my_result_helper.c.

References buf, GNUNET_MY_ResultSpec::dst, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, GNUNET_MY_ResultSpec::result_size, and size.

Referenced by GNUNET_MY_result_spec_variable_size().

78 {
79  void *buf;
80  size_t size;
81 
82  if (*results->is_null)
83  return GNUNET_SYSERR;
84  size = (size_t) rs->mysql_bind_output_length;
85 
86  if (rs->mysql_bind_output_length != size)
87  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
88 
89  buf = GNUNET_malloc (size);
90 
91  results[0].buffer = buf;
92  results[0].buffer_length = size;
93  results[0].buffer_type = MYSQL_TYPE_BLOB;
94 
95  if (0 !=
96  mysql_stmt_fetch_column (stmt,
97  results,
98  column,
99  0))
100  {
101  GNUNET_free (buf);
102  return GNUNET_SYSERR;
103  }
104 
105  *(void **) rs->dst = buf;
106  *rs->result_size = size;
107 
108  return GNUNET_OK;
109 }
size_t * result_size
Where to store actual size of the result.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ cleanup_varsize_blob()

static void cleanup_varsize_blob ( void *  cls,
struct GNUNET_MY_ResultSpec rs 
)
static

extract data from a Mysql database result at row row

Parameters
clsclosure
[in,out]rs

Definition at line 119 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, and GNUNET_free.

Referenced by GNUNET_MY_result_spec_variable_size().

121 {
122  void **ptr = (void **)rs->dst;
123 
124  if (NULL != *ptr)
125  {
126  GNUNET_free (*ptr);
127  *ptr = NULL;
128  }
129 }
void * dst
Destination for the data.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ pre_extract_fixed_blob()

static int pre_extract_fixed_blob ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid(non-existing field or NULL)

Definition at line 170 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_fixed_size().

175 {
176  results[0].buffer = rs->dst;
177  results[0].buffer_length = rs->dst_size;
178  results[0].length = &rs->mysql_bind_output_length;
179  results[0].buffer_type = MYSQL_TYPE_BLOB;
180  results[0].is_null = &rs->is_null;
181  rs->is_null = 0;
182 
183  return GNUNET_OK;
184 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ post_extract_fixed_blob()

static int post_extract_fixed_blob ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Check size of extracted fixed size data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid(non-existing field or NULL)

Definition at line 201 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_fixed_size().

206 {
207  if (*results->is_null)
208  return GNUNET_SYSERR;
209  if (rs->dst_size != rs->mysql_bind_output_length)
210  return GNUNET_SYSERR;
211  return GNUNET_OK;
212 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ pre_extract_rsa_public_key()

static int pre_extract_rsa_public_key ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 254 of file my_result_helper.c.

References GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_rsa_public_key().

259 {
260  results[0].buffer = NULL;
261  results[0].buffer_length = 0;
262  results[0].length = &rs->mysql_bind_output_length;
263  results[0].buffer_type = MYSQL_TYPE_BLOB;
264  results[0].is_null = &rs->is_null;
265  rs->is_null = 0;
266 
267  return GNUNET_OK;
268 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
Here is the caller graph for this function:

◆ post_extract_rsa_public_key()

static int post_extract_rsa_public_key ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Check size of extracted fixed size data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 285 of file my_result_helper.c.

References buf, GNUNET_MY_ResultSpec::dst, GNUNET_CRYPTO_rsa_public_key_decode(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, pk, and size.

Referenced by GNUNET_MY_result_spec_rsa_public_key().

291 {
292  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
293  void *buf;
294  size_t size;
295 
296  if (*results->is_null)
297  return GNUNET_SYSERR;
298  size = (size_t) rs->mysql_bind_output_length;
299 
300  if (rs->mysql_bind_output_length != size)
301  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
302  buf = GNUNET_malloc (size);
303 
304  results[0].buffer = buf;
305  results[0].buffer_length = size;
306  results[0].buffer_type = MYSQL_TYPE_BLOB;
307  if (0 !=
308  mysql_stmt_fetch_column (stmt,
309  results,
310  column,
311  0))
312  {
313  GNUNET_free (buf);
314  return GNUNET_SYSERR;
315  }
316 
318  size);
319  GNUNET_free (buf);
320  if (NULL == *pk)
321  {
323  "Results contains bogus public key value (fail to decode)\n");
324  return GNUNET_SYSERR;
325  }
326 
327  return GNUNET_OK;
328 }
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format. ...
Definition: crypto_rsa.c:370
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_log(kind,...)
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_rsa_public_key()

static void clean_rsa_public_key ( void *  cls,
struct GNUNET_MY_ResultSpec rs 
)
static

Function called to clean up memory allocated by a GNUNET_MY_ResultConverter.

Parameters
clsclosure
rsresult data to clean up

Definition at line 339 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, GNUNET_CRYPTO_rsa_public_key_free(), and pk.

Referenced by GNUNET_MY_result_spec_rsa_public_key().

341 {
342  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
343 
344  if (NULL != *pk)
345  {
347  *pk = NULL;
348  }
349 }
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
void * dst
Destination for the data.
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:302
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_extract_rsa_signature()

static int pre_extract_rsa_signature ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 388 of file my_result_helper.c.

References GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_rsa_signature().

393 {
394  results[0].buffer = 0;
395  results[0].buffer_length = 0;
396  results[0].length = &rs->mysql_bind_output_length;
397  results[0].buffer_type = MYSQL_TYPE_BLOB;
398  results[0].is_null = &rs->is_null;
399  rs->is_null = 0;
400 
401  return GNUNET_OK;
402 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
Here is the caller graph for this function:

◆ post_extract_rsa_signature()

static int post_extract_rsa_signature ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 418 of file my_result_helper.c.

References buf, GNUNET_MY_ResultSpec::dst, GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, and size.

Referenced by GNUNET_MY_result_spec_rsa_signature().

423 {
424  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
425  void *buf;
426  size_t size;
427 
428  if (*results->is_null)
429  return GNUNET_SYSERR;
430  size = (size_t) rs->mysql_bind_output_length;
431 
432  if (rs->mysql_bind_output_length != size)
433  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
434  buf = GNUNET_malloc (size);
435 
436  results[0].buffer = buf;
437  results[0].buffer_length = size;
438  results[0].buffer_type = MYSQL_TYPE_BLOB;
439  if (0 !=
440  mysql_stmt_fetch_column (stmt,
441  results,
442  column,
443  0))
444  {
445  GNUNET_free (buf);
446  return GNUNET_SYSERR;
447  }
448 
450  size);
451  GNUNET_free (buf);
452  if (NULL == *sig)
453  {
455  "Resuls contains bogus signature value (fails to decode)\n");
456  return GNUNET_SYSERR;
457  }
458  return GNUNET_OK;
459 }
an RSA signature
Definition: crypto_rsa.c:63
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const char *buf, size_t len)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:996
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_log(kind,...)
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_rsa_signature()

static void clean_rsa_signature ( void *  cls,
struct GNUNET_MY_ResultSpec rs 
)
static

Function called to clean up memory allocated by a GNUNET_MY_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 470 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, and GNUNET_CRYPTO_rsa_signature_free().

Referenced by GNUNET_MY_result_spec_rsa_signature().

472 {
473  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
474 
475  if (NULL != *sig)
476  {
478  *sig = NULL;
479  }
480 }
an RSA signature
Definition: crypto_rsa.c:63
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:951
void * dst
Destination for the data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_extract_string()

static int pre_extract_string ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Mysql database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non existing field or NULL)

Definition at line 518 of file my_result_helper.c.

References GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_string().

523 {
524  results[0].buffer = NULL;
525  results[0].buffer_length = 0;
526  results[0].length = &rs->mysql_bind_output_length;
527  results[0].buffer_type = MYSQL_TYPE_BLOB;
528  results[0].is_null = &rs->is_null;
529  rs->is_null = 0;
530 
531  return GNUNET_OK;
532 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
Here is the caller graph for this function:

◆ post_extract_string()

static int post_extract_string ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Check size of extracted fixed size data from a Mysql database .

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non existing field or NULL)

Definition at line 548 of file my_result_helper.c.

References buf, GNUNET_MY_ResultSpec::dst, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, and size.

Referenced by GNUNET_MY_result_spec_string().

553 {
554  size_t size = (size_t) rs->mysql_bind_output_length;
555  char *buf;
556 
557  if (rs->mysql_bind_output_length != size)
558  return GNUNET_SYSERR;
559  if (*results->is_null)
560  {
561  *(void **) rs->dst = NULL;
562  return GNUNET_OK;
563  }
564 
565  buf = GNUNET_malloc (size);
566  results[0].buffer = buf;
567  results[0].buffer_length = size;
568  results[0].buffer_type = MYSQL_TYPE_BLOB;
569 
570  if (0 !=
571  mysql_stmt_fetch_column (stmt,
572  results,
573  column,
574  0))
575  {
576  GNUNET_free (buf);
577  return GNUNET_SYSERR;
578  }
579  buf[size] = '\0';
580  *(void **) rs->dst = buf;
581  return GNUNET_OK;
582 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ pre_extract_uint16()

static int pre_extract_uint16 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 648 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_uint16().

653 {
654  results[0].buffer = rs->dst;
655  results[0].buffer_length = rs->dst_size;
656  results[0].length = &rs->mysql_bind_output_length;
657  results[0].buffer_type = MYSQL_TYPE_SHORT;
658  results[0].is_null = &rs->is_null;
659  rs->is_null = 0;
660 
661  return GNUNET_OK;
662 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ post_extract_uint16()

static int post_extract_uint16 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Check size of extracted fixed size data from a Mysql datbase.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 678 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_uint16().

683 {
684  if (rs->dst_size != rs->mysql_bind_output_length)
685  return GNUNET_SYSERR;
686  if (*results->is_null)
687  return GNUNET_SYSERR;
688  return GNUNET_OK;
689 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ pre_extract_uint32()

static int pre_extract_uint32 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extrac data from a MYSQL database result at row row.

Parameters
clsclosure
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 727 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_uint32().

732 {
733  results[0].buffer = rs->dst;
734  results[0].buffer_length = rs->dst_size;
735  results[0].length = &rs->mysql_bind_output_length;
736  results[0].buffer_type = MYSQL_TYPE_LONG;
737  results[0].is_null = &rs->is_null;
738  rs->is_null = 0;
739 
740  return GNUNET_OK;
741 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ post_extract_uint32()

static int post_extract_uint32 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extrac data from a MYSQL database result at row row.

Parameters
clsclosure
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 758 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_uint32().

763 {
764  if (rs->dst_size != rs->mysql_bind_output_length)
765  return GNUNET_SYSERR;
766  if (*results->is_null)
767  return GNUNET_SYSERR;
768  return GNUNET_OK;
769 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ pre_extract_uint64()

static int pre_extract_uint64 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Extract data from a MYSQL database result at row row.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 806 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst, GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::is_null, and GNUNET_MY_ResultSpec::mysql_bind_output_length.

Referenced by GNUNET_MY_result_spec_uint64().

811 {
812  if (sizeof (uint64_t) != rs->dst_size)
813  return GNUNET_SYSERR;
814  results[0].buffer = rs->dst;
815  results[0].buffer_length = rs->dst_size;
816  results[0].length = &rs->mysql_bind_output_length;
817  results[0].buffer_type = MYSQL_TYPE_LONGLONG;
818  results[0].is_null = &rs->is_null;
819  rs->is_null = 0;
820 
821  return GNUNET_OK;
822 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void * dst
Destination for the data.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
my_bool is_null
Memory for MySQL to notify us about NULL values.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function:

◆ post_extract_uint64()

static int post_extract_uint64 ( void *  cls,
struct GNUNET_MY_ResultSpec rs,
MYSQL_STMT *  stmt,
unsigned int  column,
MYSQL_BIND *  results 
)
static

Check size of extracted fixe size data from a Mysql database.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
GNUNET_OK if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 838 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_MY_result_spec_uint64().

843 {
844  if (sizeof (uint64_t) != rs->dst_size)
845  return GNUNET_SYSERR;
846  if (*results->is_null)
847  return GNUNET_SYSERR;
848  return GNUNET_OK;
849 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int results
Definition: gnunet-search.c:52
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...
Here is the caller graph for this function: