GNUnet  0.11.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: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 169 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().

174 {
175  results[0].buffer = rs->dst;
176  results[0].buffer_length = rs->dst_size;
177  results[0].length = &rs->mysql_bind_output_length;
178  results[0].buffer_type = MYSQL_TYPE_BLOB;
179  results[0].is_null = &rs->is_null;
180  rs->is_null = 0;
181 
182  return GNUNET_OK;
183 }
#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 200 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().

205 {
206  if (*results->is_null)
207  return GNUNET_SYSERR;
208  if (rs->dst_size != rs->mysql_bind_output_length)
209  return GNUNET_SYSERR;
210  return GNUNET_OK;
211 }
#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 252 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().

257 {
258  results[0].buffer = NULL;
259  results[0].buffer_length = 0;
260  results[0].length = &rs->mysql_bind_output_length;
261  results[0].buffer_type = MYSQL_TYPE_BLOB;
262  results[0].is_null = &rs->is_null;
263  rs->is_null = 0;
264 
265  return GNUNET_OK;
266 }
#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 283 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().

289 {
290  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
291  void *buf;
292  size_t size;
293 
294  if (*results->is_null)
295  return GNUNET_SYSERR;
296  size = (size_t) rs->mysql_bind_output_length;
297 
298  if (rs->mysql_bind_output_length != size)
299  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
300  buf = GNUNET_malloc (size);
301 
302  results[0].buffer = buf;
303  results[0].buffer_length = size;
304  results[0].buffer_type = MYSQL_TYPE_BLOB;
305  if (0 !=
306  mysql_stmt_fetch_column (stmt,
307  results,
308  column,
309  0))
310  {
311  GNUNET_free (buf);
312  return GNUNET_SYSERR;
313  }
314 
316  size);
317  GNUNET_free (buf);
318  if (NULL == *pk)
319  {
321  "Results contains bogus public key value (fail to decode)\n");
322  return GNUNET_SYSERR;
323  }
324 
325  return GNUNET_OK;
326 }
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:53
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:465
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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 337 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().

339 {
340  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
341 
342  if (NULL != *pk)
343  {
345  *pk = NULL;
346  }
347 }
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:53
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:307
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 386 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().

391 {
392  results[0].buffer = 0;
393  results[0].buffer_length = 0;
394  results[0].length = &rs->mysql_bind_output_length;
395  results[0].buffer_type = MYSQL_TYPE_BLOB;
396  results[0].is_null = &rs->is_null;
397  rs->is_null = 0;
398 
399  return GNUNET_OK;
400 }
#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 416 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().

421 {
422  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
423  void *buf;
424  size_t size;
425 
426  if (*results->is_null)
427  return GNUNET_SYSERR;
428  size = (size_t) rs->mysql_bind_output_length;
429 
430  if (rs->mysql_bind_output_length != size)
431  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
432  buf = GNUNET_malloc (size);
433 
434  results[0].buffer = buf;
435  results[0].buffer_length = size;
436  results[0].buffer_type = MYSQL_TYPE_BLOB;
437  if (0 !=
438  mysql_stmt_fetch_column (stmt,
439  results,
440  column,
441  0))
442  {
443  GNUNET_free (buf);
444  return GNUNET_SYSERR;
445  }
446 
448  size);
449  GNUNET_free (buf);
450  if (NULL == *sig)
451  {
453  "Resuls contains bogus signature value (fails to decode)\n");
454  return GNUNET_SYSERR;
455  }
456  return GNUNET_OK;
457 }
an RSA signature
Definition: crypto_rsa.c:65
#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: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:1192
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 468 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().

470 {
471  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
472 
473  if (NULL != *sig)
474  {
476  *sig = NULL;
477  }
478 }
an RSA signature
Definition: crypto_rsa.c:65
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:1112
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 516 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().

521 {
522  results[0].buffer = NULL;
523  results[0].buffer_length = 0;
524  results[0].length = &rs->mysql_bind_output_length;
525  results[0].buffer_type = MYSQL_TYPE_BLOB;
526  results[0].is_null = &rs->is_null;
527  rs->is_null = 0;
528 
529  return GNUNET_OK;
530 }
#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 546 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().

551 {
552  size_t size = (size_t) rs->mysql_bind_output_length;
553  char *buf;
554 
555  if (rs->mysql_bind_output_length != size)
556  return GNUNET_SYSERR;
557  if (*results->is_null)
558  {
559  *(void **) rs->dst = NULL;
560  return GNUNET_OK;
561  }
562 
563  buf = GNUNET_malloc (size);
564  results[0].buffer = buf;
565  results[0].buffer_length = size;
566  results[0].buffer_type = MYSQL_TYPE_BLOB;
567 
568  if (0 !=
569  mysql_stmt_fetch_column (stmt,
570  results,
571  column,
572  0))
573  {
574  GNUNET_free (buf);
575  return GNUNET_SYSERR;
576  }
577  buf[size] = '\0';
578  *(void **) rs->dst = buf;
579  return GNUNET_OK;
580 }
#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: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: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 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: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 728 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().

733 {
734  results[0].buffer = rs->dst;
735  results[0].buffer_length = rs->dst_size;
736  results[0].length = &rs->mysql_bind_output_length;
737  results[0].buffer_type = MYSQL_TYPE_LONG;
738  results[0].is_null = &rs->is_null;
739  rs->is_null = 0;
740 
741  return GNUNET_OK;
742 }
#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 759 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().

764 {
765  if (rs->dst_size != rs->mysql_bind_output_length)
766  return GNUNET_SYSERR;
767  if (*results->is_null)
768  return GNUNET_SYSERR;
769  return GNUNET_OK;
770 }
#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 808 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().

813 {
814  if (sizeof(uint64_t) != rs->dst_size)
815  return GNUNET_SYSERR;
816  results[0].buffer = rs->dst;
817  results[0].buffer_length = rs->dst_size;
818  results[0].length = &rs->mysql_bind_output_length;
819  results[0].buffer_type = MYSQL_TYPE_LONGLONG;
820  results[0].is_null = &rs->is_null;
821  rs->is_null = 0;
822 
823  return GNUNET_OK;
824 }
#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 840 of file my_result_helper.c.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_MY_result_spec_uint64().

845 {
846  if (sizeof(uint64_t) != rs->dst_size)
847  return GNUNET_SYSERR;
848  if (*results->is_null)
849  return GNUNET_SYSERR;
850  return GNUNET_OK;
851 }
#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: