GNUnet  0.19.2
my_result_helper.c File Reference

functions to extract result values More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_mysql_compat.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 database. 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)
 Extract 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)
 Extract 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 fixed-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 45 of file my_result_helper.c.

50 {
51  results[0].buffer = NULL;
52  results[0].buffer_length = 0;
53  results[0].length = &rs->mysql_bind_output_length;
54  results[0].is_null = &rs->is_null;
55  rs->is_null = 0;
56 
57  return GNUNET_OK;
58 }
static unsigned int results
@ GNUNET_OK
MYSQL_BOOL is_null
Memory for MySQL to notify us about NULL values.
unsigned long mysql_bind_output_length
Location where we temporarily store the output buffer length from MySQL.

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

◆ 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 74 of file my_result_helper.c.

79 {
80  void *buf;
81  size_t size;
82 
83  if (*results->is_null)
84  return GNUNET_SYSERR;
85  size = (size_t) rs->mysql_bind_output_length;
86 
87  if (rs->mysql_bind_output_length != size)
88  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
89 
91 
92  results[0].buffer = buf;
93  results[0].buffer_length = size;
94  results[0].buffer_type = MYSQL_TYPE_BLOB;
95 
96  if (0 !=
97  mysql_stmt_fetch_column (stmt,
98  results,
99  column,
100  0))
101  {
102  GNUNET_free (buf);
103  return GNUNET_SYSERR;
104  }
105 
106  *(void **) rs->dst = buf;
107  *rs->result_size = size;
108 
109  return GNUNET_OK;
110 }
static char buf[2048]
@ GNUNET_SYSERR
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Definition: peer.c:68
void * dst
Destination for the data.
size_t * result_size
Where to store actual size of the result.

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, results, and size.

◆ 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 120 of file my_result_helper.c.

122 {
123  void **ptr = (void **) rs->dst;
124 
125  if (NULL != *ptr)
126  {
127  GNUNET_free (*ptr);
128  *ptr = NULL;
129  }
130 }

References GNUNET_MY_ResultSpec::dst, and GNUNET_free.

◆ 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 163 of file my_result_helper.c.

168 {
169  results[0].buffer = rs->dst;
170  results[0].buffer_length = rs->dst_size;
171  results[0].length = &rs->mysql_bind_output_length;
172  results[0].buffer_type = MYSQL_TYPE_BLOB;
173  results[0].is_null = &rs->is_null;
174  rs->is_null = 0;
175 
176  return GNUNET_OK;
177 }
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...

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

◆ 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 194 of file my_result_helper.c.

199 {
200  if (*results->is_null)
201  return GNUNET_SYSERR;
202  if (rs->dst_size != rs->mysql_bind_output_length)
203  return GNUNET_SYSERR;
204  return GNUNET_OK;
205 }

◆ 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 246 of file my_result_helper.c.

251 {
252  results[0].buffer = NULL;
253  results[0].buffer_length = 0;
254  results[0].length = &rs->mysql_bind_output_length;
255  results[0].buffer_type = MYSQL_TYPE_BLOB;
256  results[0].is_null = &rs->is_null;
257  rs->is_null = 0;
258 
259  return GNUNET_OK;
260 }

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

◆ 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 277 of file my_result_helper.c.

283 {
284  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
285  void *buf;
286  size_t size;
287 
288  if (*results->is_null)
289  return GNUNET_SYSERR;
290  size = (size_t) rs->mysql_bind_output_length;
291 
292  if (rs->mysql_bind_output_length != size)
293  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
294  buf = GNUNET_malloc (size);
295 
296  results[0].buffer = buf;
297  results[0].buffer_length = size;
298  results[0].buffer_type = MYSQL_TYPE_BLOB;
299  if (0 !=
300  mysql_stmt_fetch_column (stmt,
301  results,
302  column,
303  0))
304  {
305  GNUNET_free (buf);
306  return GNUNET_SYSERR;
307  }
308 
310  size);
311  GNUNET_free (buf);
312  if (NULL == *pk)
313  {
315  "Results contains bogus public key value (fail to decode)\n");
316  return GNUNET_SYSERR;
317  }
318 
319  return GNUNET_OK;
320 }
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
#define GNUNET_log(kind,...)
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:423
@ GNUNET_ERROR_TYPE_ERROR
The public information of an RSA key pair.
Definition: crypto_rsa.c:53

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, results, and size.

Here is the call 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 331 of file my_result_helper.c.

333 {
334  struct GNUNET_CRYPTO_RsaPublicKey **pk = rs->dst;
335 
336  if (NULL != *pk)
337  {
339  *pk = NULL;
340  }
341 }
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:268

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

Here is the call 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 380 of file my_result_helper.c.

385 {
386  results[0].buffer = 0;
387  results[0].buffer_length = 0;
388  results[0].length = &rs->mysql_bind_output_length;
389  results[0].buffer_type = MYSQL_TYPE_BLOB;
390  results[0].is_null = &rs->is_null;
391  rs->is_null = 0;
392 
393  return GNUNET_OK;
394 }

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

◆ 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 410 of file my_result_helper.c.

415 {
416  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
417  void *buf;
418  size_t size;
419 
420  if (*results->is_null)
421  return GNUNET_SYSERR;
422  size = (size_t) rs->mysql_bind_output_length;
423 
424  if (rs->mysql_bind_output_length != size)
425  return GNUNET_SYSERR; /* 'unsigned long' does not fit in size_t!? */
426  buf = GNUNET_malloc (size);
427 
428  results[0].buffer = buf;
429  results[0].buffer_length = size;
430  results[0].buffer_type = MYSQL_TYPE_BLOB;
431  if (0 !=
432  mysql_stmt_fetch_column (stmt,
433  results,
434  column,
435  0))
436  {
437  GNUNET_free (buf);
438  return GNUNET_SYSERR;
439  }
440 
442  size);
443  GNUNET_free (buf);
444  if (NULL == *sig)
445  {
447  "Resuls contains bogus signature value (fails to decode)\n");
448  return GNUNET_SYSERR;
449  }
450  return GNUNET_OK;
451 }
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:1039
an RSA signature
Definition: crypto_rsa.c:65

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, results, and size.

Here is the call 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 462 of file my_result_helper.c.

464 {
465  struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
466 
467  if (NULL != *sig)
468  {
470  *sig = NULL;
471  }
472 }
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:991

References GNUNET_MY_ResultSpec::dst, and GNUNET_CRYPTO_rsa_signature_free().

Here is the call 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 510 of file my_result_helper.c.

515 {
516  results[0].buffer = NULL;
517  results[0].buffer_length = 0;
518  results[0].length = &rs->mysql_bind_output_length;
519  results[0].buffer_type = MYSQL_TYPE_BLOB;
520  results[0].is_null = &rs->is_null;
521  rs->is_null = 0;
522 
523  return GNUNET_OK;
524 }

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

◆ 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 540 of file my_result_helper.c.

545 {
546  size_t size = (size_t) rs->mysql_bind_output_length;
547  char *buf;
548 
549  if (rs->mysql_bind_output_length != size)
550  return GNUNET_SYSERR;
551  if (*results->is_null)
552  {
553  *(void **) rs->dst = NULL;
554  return GNUNET_OK;
555  }
556 
557  buf = GNUNET_malloc (size);
558  results[0].buffer = buf;
559  results[0].buffer_length = size;
560  results[0].buffer_type = MYSQL_TYPE_BLOB;
561 
562  if (0 !=
563  mysql_stmt_fetch_column (stmt,
564  results,
565  column,
566  0))
567  {
568  GNUNET_free (buf);
569  return GNUNET_SYSERR;
570  }
571  buf[size] = '\0';
572  *(void **) rs->dst = buf;
573  return GNUNET_OK;
574 }

◆ 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 642 of file my_result_helper.c.

647 {
648  results[0].buffer = rs->dst;
649  results[0].buffer_length = rs->dst_size;
650  results[0].length = &rs->mysql_bind_output_length;
651  results[0].buffer_type = MYSQL_TYPE_SHORT;
652  results[0].is_null = &rs->is_null;
653  rs->is_null = 0;
654 
655  return GNUNET_OK;
656 }

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

◆ 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 database.

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 672 of file my_result_helper.c.

677 {
678  if (rs->dst_size != rs->mysql_bind_output_length)
679  return GNUNET_SYSERR;
680  if (*results->is_null)
681  return GNUNET_SYSERR;
682  return GNUNET_OK;
683 }

◆ 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

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 721 of file my_result_helper.c.

726 {
727  results[0].buffer = rs->dst;
728  results[0].buffer_length = rs->dst_size;
729  results[0].length = &rs->mysql_bind_output_length;
730  results[0].buffer_type = MYSQL_TYPE_LONG;
731  results[0].is_null = &rs->is_null;
732  rs->is_null = 0;
733 
734  return GNUNET_OK;
735 }

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

◆ 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

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 751 of file my_result_helper.c.

756 {
757  if (rs->dst_size != rs->mysql_bind_output_length)
758  return GNUNET_SYSERR;
759  if (*results->is_null)
760  return GNUNET_SYSERR;
761  return GNUNET_OK;
762 }

◆ 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 800 of file my_result_helper.c.

805 {
806  if (sizeof(uint64_t) != rs->dst_size)
807  return GNUNET_SYSERR;
808  results[0].buffer = rs->dst;
809  results[0].buffer_length = rs->dst_size;
810  results[0].length = &rs->mysql_bind_output_length;
811  results[0].buffer_type = MYSQL_TYPE_LONGLONG;
812  results[0].is_null = &rs->is_null;
813  rs->is_null = 0;
814 
815  return GNUNET_OK;
816 }

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

◆ 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 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 832 of file my_result_helper.c.

837 {
838  if (sizeof(uint64_t) != rs->dst_size)
839  return GNUNET_SYSERR;
840  if (*results->is_null)
841  return GNUNET_SYSERR;
842  return GNUNET_OK;
843 }