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:75
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:75
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:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
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:75
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:75
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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:75
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:75
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:50
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:367
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
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:50
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:299
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:75
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:61
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
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:995
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:61
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:950
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 519 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().

524 {
525  results[0].buffer = NULL;
526  results[0].buffer_length = 0;
527  results[0].length = &rs->mysql_bind_output_length;
528  results[0].buffer_type = MYSQL_TYPE_BLOB;
529  results[0].is_null = &rs->is_null;
530  rs->is_null = 0;
531 
532  return GNUNET_OK;
533 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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 549 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().

554 {
555  size_t size = (size_t)rs->mysql_bind_output_length;
556  char *buf;
557 
558  if (rs->mysql_bind_output_length != size)
559  return GNUNET_SYSERR;
560  if (*results->is_null)
561  {
562  *(void **)rs->dst = NULL;
563  return GNUNET_OK;
564  }
565 
566  buf = GNUNET_malloc(size);
567  results[0].buffer = buf;
568  results[0].buffer_length = size;
569  results[0].buffer_type = MYSQL_TYPE_BLOB;
570 
571  if (0 !=
572  mysql_stmt_fetch_column(stmt,
573  results,
574  column,
575  0))
576  {
577  GNUNET_free(buf);
578  return GNUNET_SYSERR;
579  }
580  buf[size] = '\0';
581  *(void **)rs->dst = buf;
582  return GNUNET_OK;
583 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
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 651 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().

656 {
657  results[0].buffer = rs->dst;
658  results[0].buffer_length = rs->dst_size;
659  results[0].length = &rs->mysql_bind_output_length;
660  results[0].buffer_type = MYSQL_TYPE_SHORT;
661  results[0].is_null = &rs->is_null;
662  rs->is_null = 0;
663 
664  return GNUNET_OK;
665 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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 681 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().

686 {
687  if (rs->dst_size != rs->mysql_bind_output_length)
688  return GNUNET_SYSERR;
689  if (*results->is_null)
690  return GNUNET_SYSERR;
691  return GNUNET_OK;
692 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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 731 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().

736 {
737  results[0].buffer = rs->dst;
738  results[0].buffer_length = rs->dst_size;
739  results[0].length = &rs->mysql_bind_output_length;
740  results[0].buffer_type = MYSQL_TYPE_LONG;
741  results[0].is_null = &rs->is_null;
742  rs->is_null = 0;
743 
744  return GNUNET_OK;
745 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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 762 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().

767 {
768  if (rs->dst_size != rs->mysql_bind_output_length)
769  return GNUNET_SYSERR;
770  if (*results->is_null)
771  return GNUNET_SYSERR;
772  return GNUNET_OK;
773 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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 811 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().

816 {
817  if (sizeof(uint64_t) != rs->dst_size)
818  return GNUNET_SYSERR;
819  results[0].buffer = rs->dst;
820  results[0].buffer_length = rs->dst_size;
821  results[0].length = &rs->mysql_bind_output_length;
822  results[0].buffer_type = MYSQL_TYPE_LONGLONG;
823  results[0].is_null = &rs->is_null;
824  rs->is_null = 0;
825 
826  return GNUNET_OK;
827 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
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 843 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_MY_result_spec_uint64().

848 {
849  if (sizeof(uint64_t) != rs->dst_size)
850  return GNUNET_SYSERR;
851  if (*results->is_null)
852  return GNUNET_SYSERR;
853  return GNUNET_OK;
854 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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: