GNUnet 0.22.1
sq_result_helper.c File Reference

helper functions for queries More...

#include "platform.h"
#include "gnunet_sq_lib.h"
Include dependency graph for sq_result_helper.c:

Go to the source code of this file.

Functions

static int extract_var_blob (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract variable-sized binary data from a Postgres database result at row row. More...
 
static void clean_var_blob (void *cls)
 Cleanup memory allocated by extract_var_blob(). More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_variable_size (void **dst, size_t *sptr)
 Variable-size result expected. More...
 
static int extract_fixed_blob (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract fixed-sized binary data from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_fixed_size (void *dst, size_t dst_size)
 Fixed-size result expected. More...
 
static int extract_utf8_string (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract fixed-sized binary data from a Postgres database result at row row. More...
 
static void clean_utf8_string (void *cls)
 Cleanup memory allocated by extract_var_blob(). More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_string (char **dst)
 0-terminated string expected. More...
 
static int extract_rsa_pub (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_rsa_pub (void *cls)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa)
 RSA public key expected. More...
 
static int extract_rsa_sig (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_rsa_sig (void *cls)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig)
 RSA signature expected. More...
 
static int extract_abs_time (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract absolute time value from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at)
 Absolute time expected. More...
 
static int extract_abs_time_nbo (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract absolute time value in NBO from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at)
 Absolute time expected. More...
 
static int extract_uint16 (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract 16-bit integer from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint16 (uint16_t *u16)
 uint16_t expected. More...
 
static int extract_uint32 (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract 32-bit integer from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint32 (uint32_t *u32)
 uint32_t expected. More...
 
static int extract_uint64 (void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
 Extract 64-bit integer from a Postgres database result at row row. More...
 
struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint64 (uint64_t *u64)
 uint64_t expected. More...
 

Detailed Description

helper functions for queries

Author
Christian Grothoff

Definition in file sq_result_helper.c.

Function Documentation

◆ extract_var_blob()

static int extract_var_blob ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract variable-sized binary data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result (actually a void **)
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 42 of file sq_result_helper.c.

47{
48 int have;
49 const void *ret;
50 void **rdst = (void **) dst;
51
52 if (SQLITE_NULL ==
53 sqlite3_column_type (result,
54 column))
55 {
56 *rdst = NULL;
57 *dst_size = 0;
58 return GNUNET_YES;
59 }
60
61 if (SQLITE_BLOB !=
62 sqlite3_column_type (result,
63 column))
64 {
65 GNUNET_break (0);
66 return GNUNET_SYSERR;
67 }
68 /* sqlite manual says to invoke 'sqlite3_column_blob()'
69 before calling sqlite3_column_bytes() */
70 ret = sqlite3_column_blob (result,
71 column);
72 have = sqlite3_column_bytes (result,
73 column);
74 if (have < 0)
75 {
76 GNUNET_break (0);
77 return GNUNET_SYSERR;
78 }
79 *dst_size = have;
80 if (0 == have)
81 {
82 *rdst = NULL;
83 return GNUNET_OK;
84 }
85 *rdst = GNUNET_malloc (have);
86 GNUNET_memcpy (*rdst,
87 ret,
88 have);
89 return GNUNET_OK;
90}
static int ret
Final status code.
Definition: gnunet-arm.c:93
static int result
Global testing status.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_malloc(size)
Wrapper around malloc.

References GNUNET_break, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, result, and ret.

Referenced by GNUNET_SQ_result_spec_variable_size().

Here is the caller graph for this function:

◆ clean_var_blob()

static void clean_var_blob ( void *  cls)
static

Cleanup memory allocated by extract_var_blob().

Parameters
clspointer to pointer of allocation

Definition at line 99 of file sq_result_helper.c.

100{
101 void **dptr = (void **) cls;
102
103 if (NULL != *dptr)
104 {
105 GNUNET_free (*dptr);
106 *dptr = NULL;
107 }
108}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

Referenced by GNUNET_SQ_result_spec_variable_size().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_variable_size()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_variable_size ( void **  dst,
size_t *  sptr 
)

Variable-size result expected.

Parameters
[out]dstwhere to store the result, allocated
[out]sptrwhere to store the size of dst
Returns
array entry for the result specification to use

Definition at line 119 of file sq_result_helper.c.

121{
122 struct GNUNET_SQ_ResultSpec rs = {
124 .cleaner = &clean_var_blob,
125 .dst = dst,
126 .cls = dst,
127 .result_size = sptr,
128 .num_params = 1
129 };
130
131 return rs;
132}
static void clean_var_blob(void *cls)
Cleanup memory allocated by extract_var_blob().
static int extract_var_blob(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract variable-sized binary data from a Postgres database result at row row.
Description of a DB result cell.
GNUNET_SQ_ResultConverter conv
What is the format of the result?
void * dst
Destination for the data.

References clean_var_blob(), GNUNET_SQ_ResultSpec::conv, GNUNET_SQ_ResultSpec::dst, and extract_var_blob().

Referenced by execute_get(), get_any(), get_records_and_call_iterator(), get_typed(), namecache_sqlite_lookup_block(), peerstore_sqlite_iterate_records(), sqlite_plugin_del(), and sqlite_plugin_get_closest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_fixed_blob()

static int extract_fixed_blob ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract fixed-sized binary data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 148 of file sq_result_helper.c.

153{
154 int have;
155 const void *ret;
156
157 if ((0 == *dst_size) &&
158 (SQLITE_NULL ==
159 sqlite3_column_type (result,
160 column)))
161 {
162 return GNUNET_YES;
163 }
164
165 if (SQLITE_BLOB !=
166 sqlite3_column_type (result,
167 column))
168 {
169 GNUNET_break (0);
170 return GNUNET_SYSERR;
171 }
172 /* sqlite manual says to invoke 'sqlite3_column_blob()'
173 before calling sqlite3_column_bytes() */
174 ret = sqlite3_column_blob (result,
175 column);
176 have = sqlite3_column_bytes (result,
177 column);
178 if (*dst_size != have)
179 {
180 GNUNET_break (0);
181 return GNUNET_SYSERR;
182 }
183 GNUNET_memcpy (dst,
184 ret,
185 have);
186 return GNUNET_OK;
187}

References GNUNET_SQ_ResultSpec::dst, GNUNET_SQ_ResultSpec::dst_size, GNUNET_break, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, result, and ret.

Referenced by GNUNET_SQ_result_spec_fixed_size().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_fixed_size()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_fixed_size ( void *  dst,
size_t  dst_size 
)

Fixed-size result expected.

Parameters
[out]dstwhere to store the result
dst_sizenumber of bytes in dst
Returns
array entry for the result specification to use

Definition at line 198 of file sq_result_helper.c.

200{
201 struct GNUNET_SQ_ResultSpec rs = {
203 .dst = dst,
204 .dst_size = dst_size,
205 .num_params = 1
206 };
207
208 return rs;
209}
static int extract_fixed_blob(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract fixed-sized binary data from a Postgres database result at row row.
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_SQ_ResultSpec::conv, GNUNET_SQ_ResultSpec::dst, GNUNET_SQ_ResultSpec::dst_size, and extract_fixed_blob().

Here is the call graph for this function:

◆ extract_utf8_string()

static int extract_utf8_string ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract fixed-sized binary data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 225 of file sq_result_helper.c.

230{
231 const char *text;
232 char **rdst = dst;
233
234 if (SQLITE_NULL ==
235 sqlite3_column_type (result,
236 column))
237 {
238 *rdst = NULL;
239 return GNUNET_OK;
240 }
241 if (SQLITE_TEXT !=
242 sqlite3_column_type (result,
243 column))
244 {
245 GNUNET_break (0);
246 return GNUNET_SYSERR;
247 }
248 /* sqlite manual guarantees that 'sqlite3_column_text()'
249 is 0-terminated */
250 text = (const char *) sqlite3_column_text (result,
251 column);
252 if (NULL == text)
253 {
254 GNUNET_break (0);
255 return GNUNET_SYSERR;
256 }
257 *dst_size = strlen (text) + 1;
258 *rdst = GNUNET_strdup (text);
259 return GNUNET_OK;
260}
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.

References GNUNET_SQ_ResultSpec::dst, GNUNET_SQ_ResultSpec::dst_size, GNUNET_break, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, and result.

Referenced by GNUNET_SQ_result_spec_string().

Here is the caller graph for this function:

◆ clean_utf8_string()

static void clean_utf8_string ( void *  cls)
static

Cleanup memory allocated by extract_var_blob().

Parameters
clspointer to pointer of allocation

Definition at line 269 of file sq_result_helper.c.

270{
271 char **dptr = (char **) cls;
272
273 if (NULL != *dptr)
274 {
275 GNUNET_free (*dptr);
276 *dptr = NULL;
277 }
278}

References GNUNET_SQ_ResultSpec::cls, and GNUNET_free.

Referenced by GNUNET_SQ_result_spec_string().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_string()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_string ( char **  dst)

0-terminated string expected.

Parameters
[out]dstwhere to store the result, allocated
Returns
array entry for the result specification to use

Definition at line 288 of file sq_result_helper.c.

289{
290 struct GNUNET_SQ_ResultSpec rs = {
292 .cleaner = &clean_utf8_string,
293 .cls = dst,
294 .dst = dst,
295 .num_params = 1
296 };
297
298 return rs;
299}
static int extract_utf8_string(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract fixed-sized binary data from a Postgres database result at row row.
static void clean_utf8_string(void *cls)
Cleanup memory allocated by extract_var_blob().

References clean_utf8_string(), GNUNET_SQ_ResultSpec::conv, GNUNET_SQ_ResultSpec::dst, and extract_utf8_string().

Referenced by get_records_and_call_iterator(), and peerstore_sqlite_iterate_records().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_rsa_pub()

static int extract_rsa_pub ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 315 of file sq_result_helper.c.

320{
321 struct GNUNET_CRYPTO_RsaPublicKey **pk = dst;
322 int have;
323 const void *ret;
324
325 if (SQLITE_BLOB !=
326 sqlite3_column_type (result,
327 column))
328 {
329 GNUNET_break (0);
330 return GNUNET_SYSERR;
331 }
332 /* sqlite manual says to invoke 'sqlite3_column_blob()'
333 before calling sqlite3_column_bytes() */
334 ret = sqlite3_column_blob (result,
335 column);
336 have = sqlite3_column_bytes (result,
337 column);
338 if (have < 0)
339 {
340 GNUNET_break (0);
341 return GNUNET_SYSERR;
342 }
343
345 have);
346 if (NULL == *pk)
347 {
348 GNUNET_break (0);
349 return GNUNET_SYSERR;
350 }
351 return GNUNET_OK;
352}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
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
The public information of an RSA key pair.
Definition: crypto_rsa.c:53

References GNUNET_break, GNUNET_CRYPTO_rsa_public_key_decode(), GNUNET_OK, GNUNET_SYSERR, pk, result, and ret.

Referenced by GNUNET_SQ_result_spec_rsa_public_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_rsa_pub()

static void clean_rsa_pub ( void *  cls)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure

Definition at line 362 of file sq_result_helper.c.

363{
364 struct GNUNET_CRYPTO_RsaPublicKey **pk = cls;
365
366 if (NULL != *pk)
367 {
369 *pk = NULL;
370 }
371}
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_CRYPTO_rsa_public_key_free(), and pk.

Referenced by GNUNET_SQ_result_spec_rsa_public_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_rsa_public_key()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_rsa_public_key ( struct GNUNET_CRYPTO_RsaPublicKey **  rsa)

RSA public key expected.

Parameters
[out]rsawhere to store the result
Returns
array entry for the result specification to use

Definition at line 381 of file sq_result_helper.c.

382{
383 struct GNUNET_SQ_ResultSpec rs = {
385 .cleaner = &clean_rsa_pub,
386 .dst = rsa,
387 .cls = rsa,
388 .num_params = 1
389 };
390
391 return rs;
392}
static void clean_rsa_pub(void *cls)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
static int extract_rsa_pub(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References clean_rsa_pub(), GNUNET_SQ_ResultSpec::conv, and extract_rsa_pub().

Here is the call graph for this function:

◆ extract_rsa_sig()

static int extract_rsa_sig ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 408 of file sq_result_helper.c.

413{
414 struct GNUNET_CRYPTO_RsaSignature **sig = dst;
415 int have;
416 const void *ret;
417
418 if (SQLITE_BLOB !=
419 sqlite3_column_type (result,
420 column))
421 {
422 GNUNET_break (0);
423 return GNUNET_SYSERR;
424 }
425 /* sqlite manual says to invoke 'sqlite3_column_blob()'
426 before calling sqlite3_column_bytes() */
427 ret = sqlite3_column_blob (result,
428 column);
429 have = sqlite3_column_bytes (result,
430 column);
431 if (have < 0)
432 {
433 GNUNET_break (0);
434 return GNUNET_SYSERR;
435 }
436
438 have);
439 if (NULL == *sig)
440 {
441 GNUNET_break (0);
442 return GNUNET_SYSERR;
443 }
444 return GNUNET_OK;
445}
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:1063
an RSA signature
Definition: crypto_rsa.c:65

References GNUNET_break, GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_OK, GNUNET_SYSERR, result, and ret.

Referenced by GNUNET_SQ_result_spec_rsa_signature().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_rsa_sig()

static void clean_rsa_sig ( void *  cls)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsresult data to clean up

Definition at line 455 of file sq_result_helper.c.

456{
457 struct GNUNET_CRYPTO_RsaSignature **sig = cls;
458
459 if (NULL != *sig)
460 {
462 *sig = NULL;
463 }
464}
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:1015

References GNUNET_CRYPTO_rsa_signature_free().

Referenced by GNUNET_SQ_result_spec_rsa_signature().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_rsa_signature()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_rsa_signature ( struct GNUNET_CRYPTO_RsaSignature **  sig)

RSA signature expected.

Parameters
[out]sigwhere to store the result;
Returns
array entry for the result specification to use

Definition at line 474 of file sq_result_helper.c.

475{
476 struct GNUNET_SQ_ResultSpec rs = {
478 .cleaner = &clean_rsa_sig,
479 .dst = sig,
480 .cls = sig,
481 .num_params = 1
482 };
483
484 return rs;
485}
static int extract_rsa_sig(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_rsa_sig(void *cls)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

References clean_rsa_sig(), GNUNET_SQ_ResultSpec::conv, and extract_rsa_sig().

Here is the call graph for this function:

◆ extract_abs_time()

static int extract_abs_time ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract absolute time value from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 501 of file sq_result_helper.c.

506{
507 struct GNUNET_TIME_Absolute *u = dst;
508 struct GNUNET_TIME_Absolute t;
509
510 GNUNET_assert (sizeof(uint64_t) == *dst_size);
511 if (SQLITE_INTEGER !=
512 sqlite3_column_type (result,
513 column))
514 {
515 GNUNET_break (0);
516 return GNUNET_SYSERR;
517 }
518 t.abs_value_us = (uint64_t) sqlite3_column_int64 (result,
519 column);
520 if (INT64_MAX == t.abs_value_us)
522 *u = t;
523 return GNUNET_OK;
524}
static mp_limb_t u[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
static struct GNUNET_SCHEDULER_Task * t
Main task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, result, t, and u.

Referenced by GNUNET_SQ_result_spec_absolute_time().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_absolute_time()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_absolute_time ( struct GNUNET_TIME_Absolute at)

Absolute time expected.

Parameters
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 534 of file sq_result_helper.c.

535{
536 struct GNUNET_SQ_ResultSpec rs = {
538 .dst = at,
539 .dst_size = sizeof(struct GNUNET_TIME_Absolute),
540 .num_params = 1
541 };
542
543 return rs;
544}
static int extract_abs_time(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract absolute time value from a Postgres database result at row row.

References GNUNET_SQ_ResultSpec::conv, and extract_abs_time().

Referenced by execute_get(), get_any(), get_typed(), peerstore_sqlite_iterate_records(), and sqlite_plugin_get_closest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_abs_time_nbo()

static int extract_abs_time_nbo ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract absolute time value in NBO from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 560 of file sq_result_helper.c.

565{
566 struct GNUNET_TIME_AbsoluteNBO *u = dst;
567 struct GNUNET_TIME_Absolute t;
568
569 GNUNET_assert (sizeof(uint64_t) == *dst_size);
570 if (SQLITE_INTEGER !=
571 sqlite3_column_type (result,
572 column))
573 {
574 GNUNET_break (0);
575 return GNUNET_SYSERR;
576 }
577 t.abs_value_us = (uint64_t) sqlite3_column_int64 (result,
578 column);
579 if (INT64_MAX == t.abs_value_us)
582 return GNUNET_OK;
583}
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
Time for absolute time used by GNUnet, in microseconds and in network byte order.

References GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_hton(), GNUNET_TIME_UNIT_FOREVER_ABS, result, t, and u.

Referenced by GNUNET_SQ_result_spec_absolute_time_nbo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_absolute_time_nbo()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_absolute_time_nbo ( struct GNUNET_TIME_AbsoluteNBO at)

Absolute time expected.

Parameters
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 593 of file sq_result_helper.c.

594{
595 struct GNUNET_SQ_ResultSpec rs = {
597 .dst = at,
598 .dst_size = sizeof(struct GNUNET_TIME_AbsoluteNBO),
599 .num_params = 1
600 };
601
602 return rs;
603}
static int extract_abs_time_nbo(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract absolute time value in NBO from a Postgres database result at row row.

References GNUNET_SQ_ResultSpec::conv, and extract_abs_time_nbo().

Here is the call graph for this function:

◆ extract_uint16()

static int extract_uint16 ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract 16-bit integer from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 619 of file sq_result_helper.c.

624{
625 uint64_t v;
626 uint16_t *u = dst;
627
628 GNUNET_assert (sizeof(uint16_t) == *dst_size);
629 if (SQLITE_INTEGER !=
630 sqlite3_column_type (result,
631 column))
632 {
633 GNUNET_break (0);
634 return GNUNET_SYSERR;
635 }
636 v = (uint64_t) sqlite3_column_int64 (result,
637 column);
638 if (v > UINT16_MAX)
639 {
640 GNUNET_break (0);
641 return GNUNET_SYSERR;
642 }
643 *u = (uint16_t) v;
644 return GNUNET_OK;
645}

References GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, result, and u.

Referenced by GNUNET_SQ_result_spec_uint16().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_uint16()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint16 ( uint16_t *  u16)

uint16_t expected.

Parameters
[out]u16where to store the result
Returns
array entry for the result specification to use

Definition at line 655 of file sq_result_helper.c.

656{
657 struct GNUNET_SQ_ResultSpec rs = {
659 .dst = u16,
660 .dst_size = sizeof(uint16_t),
661 .num_params = 1
662 };
663
664 return rs;
665}
static int extract_uint16(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract 16-bit integer from a Postgres database result at row row.
unsigned int num_params
Number of parameters (columns) eaten by this operation.

References GNUNET_SQ_ResultSpec::conv, extract_uint16(), and GNUNET_SQ_ResultSpec::num_params.

Here is the call graph for this function:

◆ extract_uint32()

static int extract_uint32 ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract 32-bit integer from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
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 sq_result_helper.c.

686{
687 uint64_t v;
688 uint32_t *u = dst;
689
690 GNUNET_assert (sizeof(uint32_t) == *dst_size);
691 if (SQLITE_INTEGER !=
692 sqlite3_column_type (result,
693 column))
694 {
695 GNUNET_break (0);
696 return GNUNET_SYSERR;
697 }
698 v = (uint64_t) sqlite3_column_int64 (result,
699 column);
700 if (v > UINT32_MAX)
701 {
702 GNUNET_break (0);
703 return GNUNET_SYSERR;
704 }
705 *u = (uint32_t) v;
706 return GNUNET_OK;
707}

References GNUNET_SQ_ResultSpec::dst, GNUNET_SQ_ResultSpec::dst_size, GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, result, and u.

Referenced by GNUNET_SQ_result_spec_uint32().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_uint32()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint32 ( uint32_t *  u32)

uint32_t expected.

Parameters
[out]u32where to store the result
Returns
array entry for the result specification to use

Definition at line 717 of file sq_result_helper.c.

718{
719 struct GNUNET_SQ_ResultSpec rs = {
721 .dst = u32,
722 .dst_size = sizeof(uint32_t),
723 .num_params = 1
724 };
725
726 return rs;
727}
static int extract_uint32(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract 32-bit integer from a Postgres database result at row row.

References GNUNET_SQ_ResultSpec::conv, extract_uint32(), and GNUNET_SQ_ResultSpec::num_params.

Referenced by execute_get(), get_any(), get_records_and_call_iterator(), get_typed(), and sqlite_plugin_get_closest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_uint64()

static int extract_uint64 ( void *  cls,
sqlite3_stmt *  result,
unsigned int  column,
size_t *  dst_size,
void *  dst 
)
static

Extract 64-bit integer from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
columncolumn to extract data from
[in,out]dst_sizewhere to store size of result, may be NULL
[out]dstwhere to store the result
Returns
GNUNET_YES if all results could be extracted GNUNET_SYSERR if a result was invalid (non-existing field or NULL)

Definition at line 743 of file sq_result_helper.c.

748{
749 uint64_t *u = dst;
750
751 GNUNET_assert (sizeof(uint64_t) == *dst_size);
752 if (SQLITE_INTEGER !=
753 sqlite3_column_type (result,
754 column))
755 {
756 GNUNET_break (0);
757 return GNUNET_SYSERR;
758 }
759 *u = (uint64_t) sqlite3_column_int64 (result,
760 column);
761 return GNUNET_OK;
762}

References GNUNET_SQ_ResultSpec::dst, GNUNET_SQ_ResultSpec::dst_size, GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, result, and u.

Referenced by GNUNET_SQ_result_spec_uint64().

Here is the caller graph for this function:

◆ GNUNET_SQ_result_spec_uint64()

struct GNUNET_SQ_ResultSpec GNUNET_SQ_result_spec_uint64 ( uint64_t *  u64)

uint64_t expected.

Parameters
[out]u64where to store the result
Returns
array entry for the result specification to use

Definition at line 772 of file sq_result_helper.c.

773{
774 struct GNUNET_SQ_ResultSpec rs = {
776 .dst = u64,
777 .dst_size = sizeof(uint64_t),
778 .num_params = 1
779 };
780
781 return rs;
782}
static int extract_uint64(void *cls, sqlite3_stmt *result, unsigned int column, size_t *dst_size, void *dst)
Extract 64-bit integer from a Postgres database result at row row.

References GNUNET_SQ_ResultSpec::conv, extract_uint64(), and GNUNET_SQ_ResultSpec::num_params.

Referenced by execute_get(), get_records_and_call_iterator(), peerstore_sqlite_iterate_records(), and sqlite_plugin_del().

Here is the call graph for this function:
Here is the caller graph for this function: