GNUnet 0.21.1
pq_result_helper.c File Reference

functions to extract result values More...

#include "platform.h"
#include "gnunet_time_lib.h"
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_pq_lib.h"
#include "pq.h"
Include dependency graph for pq_result_helper.c:

Go to the source code of this file.

Data Structures

struct  array_result_cls
 Closure for the array result specifications. More...
 

Macros

#define FAIL_IF(cond)
 

Functions

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_allow_null (struct GNUNET_PQ_ResultSpec rs, bool *is_null)
 Allow NULL value to be found in the database for the given value. More...
 
static void clean_varsize_blob (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
static enum GNUNET_GenericReturnValue extract_varsize_blob (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr)
 Variable-size result expected. More...
 
static enum GNUNET_GenericReturnValue extract_fixed_blob (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size)
 Fixed-size result expected. More...
 
static enum GNUNET_GenericReturnValue extract_rsa_public_key (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_rsa_public_key (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_RsaPublicKey **rsa)
 RSA public key expected. More...
 
static enum GNUNET_GenericReturnValue extract_rsa_signature (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_rsa_signature (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
 RSA signature expected. More...
 
static enum GNUNET_GenericReturnValue extract_string (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_string (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string (const char *name, char **dst)
 0-terminated string expected. More...
 
static enum GNUNET_GenericReturnValue extract_bool (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_bool (const char *name, bool *dst)
 boolean expected. More...
 
static enum GNUNET_GenericReturnValue extract_rel_time (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_relative_time (const char *name, struct GNUNET_TIME_Relative *rt)
 Relative time expected. More...
 
static enum GNUNET_GenericReturnValue extract_abs_time (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at)
 Absolute time expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
 Absolute time expected. More...
 
static enum GNUNET_GenericReturnValue extract_timestamp (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp (const char *name, struct GNUNET_TIME_Timestamp *at)
 Timestamp expected. More...
 
static enum GNUNET_GenericReturnValue extract_timestamp_nbo (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO *at)
 Timestamp expected. More...
 
static enum GNUNET_GenericReturnValue extract_uint16 (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16)
 uint16_t expected. More...
 
static enum GNUNET_GenericReturnValue extract_uint32 (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32)
 uint32_t expected. More...
 
static enum GNUNET_GenericReturnValue extract_uint64 (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64)
 uint64_t expected. More...
 
static enum GNUNET_GenericReturnValue extract_int64 (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int64 (const char *name, int64_t *i64)
 int64_t expected. More...
 
static enum GNUNET_GenericReturnValue extract_array_generic (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result as array of a specific type from row row. More...
 
static void array_cleanup (void *cls, void *rd)
 Cleanup of the data and closure of an array spec. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_bool (struct GNUNET_PQ_Context *db, const char *name, size_t *num, bool **dst)
 array of bool expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint16 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint16_t **dst)
 array of uint16_t expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint32 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint32_t **dst)
 array of uint32_t expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint64 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint64_t **dst)
 array of uint64_t expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_abs_time (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Absolute **dst)
 array of absolute time expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_rel_time (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Relative **dst)
 array of relative time expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_timestamp (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Timestamp **dst)
 array of relative time expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_variable_size (struct GNUNET_PQ_Context *db, const char *name, size_t *num, size_t **sizes, void **dst)
 Array of variable-size result expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_fixed_size (struct GNUNET_PQ_Context *db, const char *name, size_t size, size_t *num, void **dst)
 Array of fixed-size result expected. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_string (struct GNUNET_PQ_Context *db, const char *name, size_t *num, char **dst)
 Array of 0-terminated strings expected. More...
 
static enum GNUNET_GenericReturnValue extract_blind_sign_pub (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_blind_sign_pub (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_pub (const char *name, struct GNUNET_CRYPTO_BlindSignPublicKey *pub)
 Blind sign public key expected. More...
 
static enum GNUNET_GenericReturnValue extract_blind_sign_priv (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
 Extract data from a Postgres database result at row row. More...
 
static void clean_blind_sign_priv (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More...
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_priv (const char *name, struct GNUNET_CRYPTO_BlindSignPrivateKey *priv)
 Blind sign private key expected. More...
 

Detailed Description

functions to extract result values

Author
Christian Grothoff
Özgür Kesim

Definition in file pq_result_helper.c.

Macro Definition Documentation

◆ FAIL_IF

#define FAIL_IF (   cond)
Value:
do { \
if ((cond)) \
{ \
GNUNET_break (! (cond)); \
goto FAIL; \
} \
} while (0)
@ FAIL

Function Documentation

◆ GNUNET_PQ_result_spec_allow_null()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_allow_null ( struct GNUNET_PQ_ResultSpec  rs,
bool *  is_null 
)

Allow NULL value to be found in the database for the given value.

Parameters
rsresult spec entry to modify
[out]is_nulllocation set to 'true' if the value was indeed NULL, set to 'false' if the value was non-NULL
Returns
array entry for the result specification to use

Definition at line 35 of file pq_result_helper.c.

37{
38 struct GNUNET_PQ_ResultSpec rsr;
39
40 rsr = rs;
41 rsr.is_nullable = true;
42 rsr.is_null = is_null;
43 return rsr;
44}
Description of a DB result cell.
bool * is_null
Points to a location where we should store "true" if the result found is NULL, and otherwise "false".
bool is_nullable
True if NULL is allowed for a value in the database.

References GNUNET_PQ_ResultSpec::is_null, and GNUNET_PQ_ResultSpec::is_nullable.

Referenced by handle_results().

Here is the caller graph for this function:

◆ clean_varsize_blob()

static void clean_varsize_blob ( void *  cls,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 55 of file pq_result_helper.c.

57{
58 void **dst = rd;
59
60 (void) cls;
61 if (NULL != *dst)
62 {
63 GNUNET_free (*dst);
64 *dst = NULL;
65 }
66}
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_free, and rd.

Referenced by GNUNET_PQ_result_spec_variable_size().

Here is the caller graph for this function:

◆ extract_varsize_blob()

static enum GNUNET_GenericReturnValue extract_varsize_blob ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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)

Definition at line 83 of file pq_result_helper.c.

89{
90 size_t len;
91 const char *res;
92 void *idst;
93 int fnum;
94
95 (void) cls;
96 *dst_size = 0;
97 *((void **) dst) = NULL;
98
99 fnum = PQfnumber (result,
100 fname);
101 if (fnum < 0)
102 {
103 GNUNET_break (0);
104 return GNUNET_SYSERR;
105 }
106 if (PQgetisnull (result,
107 row,
108 fnum))
109 return GNUNET_NO;
110 /* if a field is null, continue but
111 * remember that we now return a different result */
112 len = PQgetlength (result,
113 row,
114 fnum);
115 res = PQgetvalue (result,
116 row,
117 fnum);
118 GNUNET_assert (NULL != res);
119 *dst_size = len;
120 idst = GNUNET_malloc (len);
121 *((void **) dst) = idst;
122 GNUNET_memcpy (idst,
123 res,
124 len);
125 return GNUNET_OK;
126}
static char * res
Currently read line or NULL on EOF.
static int result
Global testing status.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#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_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_variable_size().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_variable_size()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_variable_size ( const char *  name,
void **  dst,
size_t *  sptr 
)

Variable-size result expected.

Parameters
namename of the field in the table
[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 130 of file pq_result_helper.c.

133{
134 struct GNUNET_PQ_ResultSpec res = {
135 .conv = &extract_varsize_blob,
136 .cleaner = &clean_varsize_blob,
137 .dst = (void *) (dst),
138 .fname = name,
139 .result_size = sptr
140 };
141
142 return res;
143}
static char * name
Name (label) of the records to list.
static enum GNUNET_GenericReturnValue extract_varsize_blob(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_varsize_blob(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
void * dst
Destination for the data.

References clean_varsize_blob(), GNUNET_PQ_ResultSpec::dst, extract_varsize_blob(), name, and res.

Referenced by extract_result_cb(), handle_results(), namecache_postgres_lookup_block(), parse_result_call_iterator(), and process_result().

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

◆ extract_fixed_blob()

static enum GNUNET_GenericReturnValue extract_fixed_blob ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract from
[in]dst_sizedesired size, never 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 160 of file pq_result_helper.c.

166{
167 size_t len;
168 const char *res;
169 int fnum;
170
171 (void) cls;
172 fnum = PQfnumber (result,
173 fname);
174 if (fnum < 0)
175 {
176 GNUNET_break (0);
178 "Result does not have field %s\n",
179 fname);
180 return GNUNET_SYSERR;
181 }
182 if (PQgetisnull (result,
183 row,
184 fnum))
185 return GNUNET_NO;
186 /* if a field is null, continue but
187 * remember that we now return a different result */
188 len = PQgetlength (result,
189 row,
190 fnum);
191 if (*dst_size != len)
192 {
194 "Expected %u bytes for field `%s', got %u\n",
195 (unsigned int) *dst_size,
196 fname,
197 (unsigned int) len);
198 GNUNET_break (0);
199 return GNUNET_SYSERR;
200 }
201 res = PQgetvalue (result,
202 row,
203 fnum);
204 GNUNET_assert (NULL != res);
205 GNUNET_memcpy (dst,
206 res,
207 len);
208 return GNUNET_OK;
209}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_fixed_size().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_fixed_size()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_fixed_size ( const char *  name,
void *  dst,
size_t  dst_size 
)

Fixed-size result expected.

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

Definition at line 213 of file pq_result_helper.c.

216{
217 struct GNUNET_PQ_ResultSpec res = {
218 .conv = &extract_fixed_blob,
219 .dst = (dst),
221 .fname = name
222 };
223
224 return res;
225}
static enum GNUNET_GenericReturnValue extract_fixed_blob(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
const char * fname
Field name of the desired result.
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_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, extract_fixed_blob(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_rsa_public_key()

static enum GNUNET_GenericReturnValue extract_rsa_public_key ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 242 of file pq_result_helper.c.

248{
249 struct GNUNET_CRYPTO_RsaPublicKey **pk = dst;
250 size_t len;
251 const char *res;
252 int fnum;
253
254 (void) cls;
255 *pk = NULL;
256 fnum = PQfnumber (result,
257 fname);
258 if (fnum < 0)
259 {
260 GNUNET_break (0);
261 return GNUNET_SYSERR;
262 }
263 if (PQgetisnull (result,
264 row,
265 fnum))
266 return GNUNET_NO;
267
268 /* if a field is null, continue but
269 * remember that we now return a different result */
270 len = PQgetlength (result,
271 row,
272 fnum);
273 res = PQgetvalue (result,
274 row,
275 fnum);
277 len);
278 if (NULL == *pk)
279 {
280 GNUNET_break (0);
281 return GNUNET_SYSERR;
282 }
283 return GNUNET_OK;
284}
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_NO, GNUNET_OK, GNUNET_SYSERR, pk, res, and result.

Referenced by GNUNET_PQ_result_spec_rsa_public_key().

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,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 295 of file pq_result_helper.c.

297{
299
300 (void) cls;
301 if (NULL != *pk)
302 {
304 *pk = NULL;
305 }
306}
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(), pk, and rd.

Referenced by GNUNET_PQ_result_spec_rsa_public_key().

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

◆ GNUNET_PQ_result_spec_rsa_public_key()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_public_key ( const char *  name,
struct GNUNET_CRYPTO_RsaPublicKey **  rsa 
)

RSA public key expected.

Parameters
namename of the field in the table
[out]rsawhere to store the result
Returns
array entry for the result specification to use

Definition at line 310 of file pq_result_helper.c.

312{
313 struct GNUNET_PQ_ResultSpec res = {
314 .conv = &extract_rsa_public_key,
315 .cleaner = &clean_rsa_public_key,
316 .dst = (void *) rsa,
317 .fname = name
318 };
319
320 return res;
321}
static void clean_rsa_public_key(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
static enum GNUNET_GenericReturnValue extract_rsa_public_key(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References clean_rsa_public_key(), extract_rsa_public_key(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_rsa_signature()

static enum GNUNET_GenericReturnValue extract_rsa_signature ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 338 of file pq_result_helper.c.

344{
345 struct GNUNET_CRYPTO_RsaSignature **sig = dst;
346 size_t len;
347 const void *res;
348 int fnum;
349
350 (void) cls;
351 *sig = NULL;
352 fnum = PQfnumber (result,
353 fname);
354 if (fnum < 0)
355 {
356 GNUNET_break (0);
357 return GNUNET_SYSERR;
358 }
359 if (PQgetisnull (result,
360 row,
361 fnum))
362 return GNUNET_NO;
363 /* if a field is null, continue but
364 * remember that we now return a different result */
365 len = PQgetlength (result,
366 row,
367 fnum);
368 res = PQgetvalue (result,
369 row,
370 fnum);
372 len);
373 if (NULL == *sig)
374 {
375 GNUNET_break (0);
376 return GNUNET_SYSERR;
377 }
378 return GNUNET_OK;
379}
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_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_rsa_signature().

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,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 390 of file pq_result_helper.c.

392{
393 struct GNUNET_CRYPTO_RsaSignature **sig = rd;
394
395 (void) cls;
396 if (NULL != *sig)
397 {
399 *sig = NULL;
400 }
401}
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(), and rd.

Referenced by GNUNET_PQ_result_spec_rsa_signature().

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

◆ GNUNET_PQ_result_spec_rsa_signature()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature ( const char *  name,
struct GNUNET_CRYPTO_RsaSignature **  sig 
)

RSA signature expected.

Parameters
namename of the field in the table
[out]sigwhere to store the result;
Returns
array entry for the result specification to use

Definition at line 405 of file pq_result_helper.c.

407{
408 struct GNUNET_PQ_ResultSpec res = {
409 .conv = &extract_rsa_signature,
410 .cleaner = &clean_rsa_signature,
411 .dst = (void *) sig,
412 .fname = name
413 };
414
415 return res;
416}
static enum GNUNET_GenericReturnValue extract_rsa_signature(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_rsa_signature(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

References clean_rsa_signature(), extract_rsa_signature(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_string()

static enum GNUNET_GenericReturnValue extract_string ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 433 of file pq_result_helper.c.

439{
440 char **str = dst;
441 size_t len;
442 const char *res;
443 int fnum;
444
445 (void) cls;
446 *str = NULL;
447 fnum = PQfnumber (result,
448 fname);
449 if (fnum < 0)
450 {
451 GNUNET_break (0);
452 return GNUNET_SYSERR;
453 }
454 if (PQgetisnull (result,
455 row,
456 fnum))
457 return GNUNET_NO;
458 /* if a field is null, continue but
459 * remember that we now return a different result */
460 len = PQgetlength (result,
461 row,
462 fnum);
463 res = PQgetvalue (result,
464 row,
465 fnum);
466 *str = GNUNET_strndup (res,
467 len);
468 if (NULL == *str)
469 {
470 GNUNET_break (0);
471 return GNUNET_SYSERR;
472 }
473 return GNUNET_OK;
474}
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::fname, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_strndup, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_string().

Here is the caller graph for this function:

◆ clean_string()

static void clean_string ( void *  cls,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 485 of file pq_result_helper.c.

487{
488 char **str = rd;
489
490 (void) cls;
491 if (NULL != *str)
492 {
493 GNUNET_free (*str);
494 *str = NULL;
495 }
496}

References GNUNET_PQ_ResultSpec::cls, GNUNET_free, and rd.

Referenced by GNUNET_PQ_result_spec_string().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_string()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string ( const char *  name,
char **  dst 
)

0-terminated string expected.

Parameters
namename of the field in the table
[out]dstwhere to store the result, allocated
Returns
array entry for the result specification to use

Definition at line 500 of file pq_result_helper.c.

502{
503 struct GNUNET_PQ_ResultSpec res = {
504 .conv = &extract_string,
505 .cleaner = &clean_string,
506 .dst = (void *) dst,
507 .fname = (name)
508 };
509
510 return res;
511}
static enum GNUNET_GenericReturnValue extract_string(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_string(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

References clean_string(), GNUNET_PQ_ResultSpec::dst, extract_string(), GNUNET_PQ_ResultSpec::fname, name, and res.

Referenced by GNUNET_PQ_run_sql(), and parse_result_call_iterator().

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

◆ extract_bool()

static enum GNUNET_GenericReturnValue extract_bool ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 528 of file pq_result_helper.c.

534{
535 bool *b = dst;
536 const uint8_t *res;
537 int fnum;
538 size_t len;
539
540 (void) cls;
541 fnum = PQfnumber (result,
542 fname);
543 if (fnum < 0)
544 {
545 GNUNET_break (0);
546 return GNUNET_SYSERR;
547 }
548 if (PQgetisnull (result,
549 row,
550 fnum))
551 return GNUNET_NO;
552 /* if a field is null, continue but
553 * remember that we now return a different result */
554 len = PQgetlength (result,
555 row,
556 fnum);
557 if (sizeof (uint8_t) != len)
558 {
559 GNUNET_break (0);
560 return GNUNET_SYSERR;
561 }
562 res = (const uint8_t *) PQgetvalue (result,
563 row,
564 fnum);
565 *b = (0 != *res);
566 return GNUNET_OK;
567}

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::fname, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_bool().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_bool()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_bool ( const char *  name,
bool *  dst 
)

boolean expected.

Parameters
namename of the field in the table
[out]dstwhere to store the result
Returns
array entry for the result specification to use

Definition at line 571 of file pq_result_helper.c.

573{
574 struct GNUNET_PQ_ResultSpec res = {
575 .conv = &extract_bool,
576 .dst = (void *) dst,
577 .fname = name
578 };
579
580 return res;
581}
static enum GNUNET_GenericReturnValue extract_bool(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst, extract_bool(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_rel_time()

static enum GNUNET_GenericReturnValue extract_rel_time ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 598 of file pq_result_helper.c.

604{
605 struct GNUNET_TIME_Relative *udst = dst;
606 const int64_t *res;
607 int fnum;
608
609 (void) cls;
610 fnum = PQfnumber (result,
611 fname);
612 if (fnum < 0)
613 {
614 GNUNET_break (0);
615 return GNUNET_SYSERR;
616 }
617 if (PQgetisnull (result,
618 row,
619 fnum))
620 return GNUNET_NO;
621 GNUNET_assert (NULL != dst);
622 if (sizeof(struct GNUNET_TIME_Relative) != *dst_size)
623 {
624 GNUNET_break (0);
625 return GNUNET_SYSERR;
626 }
627 if (sizeof(int64_t) !=
628 PQgetlength (result,
629 row,
630 fnum))
631 {
632 GNUNET_break (0);
633 return GNUNET_SYSERR;
634 }
635 res = (int64_t *) PQgetvalue (result,
636 row,
637 fnum);
638 if (INT64_MAX == GNUNET_ntohll ((uint64_t) *res))
640 else
641 udst->rel_value_us = GNUNET_ntohll ((uint64_t) *res);
642 return GNUNET_OK;
643}
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.

References GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_Relative::rel_value_us, res, and result.

Referenced by GNUNET_PQ_result_spec_relative_time().

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

◆ GNUNET_PQ_result_spec_relative_time()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_relative_time ( const char *  name,
struct GNUNET_TIME_Relative rt 
)

Relative time expected.

Parameters
namename of the field in the table
[out]rtwhere to store the result
Returns
array entry for the result specification to use

Definition at line 647 of file pq_result_helper.c.

649{
650 struct GNUNET_PQ_ResultSpec res = {
651 .conv = &extract_rel_time,
652 .dst = (void *) rt,
653 .dst_size = sizeof(*rt),
654 .fname = name
655 };
656
657 return res;
658}
static enum GNUNET_GenericReturnValue extract_rel_time(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_rel_time(), name, and res.

Here is the call graph for this function:

◆ extract_abs_time()

static enum GNUNET_GenericReturnValue extract_abs_time ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 675 of file pq_result_helper.c.

681{
682 struct GNUNET_TIME_Absolute *udst = dst;
683 const int64_t *res;
684 int fnum;
685
686 (void) cls;
687 fnum = PQfnumber (result,
688 fname);
689 if (fnum < 0)
690 {
691 GNUNET_break (0);
692 return GNUNET_SYSERR;
693 }
694 if (PQgetisnull (result,
695 row,
696 fnum))
697 return GNUNET_NO;
698 GNUNET_assert (NULL != dst);
699 if (sizeof(struct GNUNET_TIME_Absolute) != *dst_size)
700 {
701 GNUNET_break (0);
702 return GNUNET_SYSERR;
703 }
704 if (sizeof(int64_t) !=
705 PQgetlength (result,
706 row,
707 fnum))
708 {
709 GNUNET_break (0);
710 return GNUNET_SYSERR;
711 }
712 res = (int64_t *) PQgetvalue (result,
713 row,
714 fnum);
715 if (INT64_MAX == GNUNET_ntohll ((uint64_t) *res))
717 else
718 udst->abs_value_us = GNUNET_ntohll ((uint64_t) *res);
719 return GNUNET_OK;
720}
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, res, and result.

Referenced by GNUNET_PQ_result_spec_absolute_time().

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

◆ GNUNET_PQ_result_spec_absolute_time()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time ( const char *  name,
struct GNUNET_TIME_Absolute at 
)

Absolute time expected.

Parameters
namename of the field in the table
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 724 of file pq_result_helper.c.

726{
727 struct GNUNET_PQ_ResultSpec res = {
728 .conv = &extract_abs_time,
729 .dst = (void *) at,
730 .dst_size = sizeof(*at),
731 .fname = name
732 };
733
734 return res;
735}
static enum GNUNET_GenericReturnValue extract_abs_time(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_abs_time(), name, and res.

Referenced by extract_result_cb(), handle_results(), and process_result().

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

◆ GNUNET_PQ_result_spec_absolute_time_nbo()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time_nbo ( const char *  name,
struct GNUNET_TIME_AbsoluteNBO at 
)

Absolute time expected.

Parameters
namename of the field in the table
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 739 of file pq_result_helper.c.

741{
744 &at->abs_value_us__);
745
746 return res;
747}
#define GNUNET_PQ_result_spec_auto_from_type(name, dst)
We expect a fixed-size result, with size determined by the type of * dst
uint64_t abs_value_us__
The actual value (in network byte order).

References GNUNET_PQ_result_spec_auto_from_type, name, and res.

◆ extract_timestamp()

static enum GNUNET_GenericReturnValue extract_timestamp ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 764 of file pq_result_helper.c.

770{
771 struct GNUNET_TIME_Timestamp *udst = dst;
772 struct GNUNET_TIME_Absolute abs;
773 const int64_t *res;
774 int fnum;
775
776 (void) cls;
777 fnum = PQfnumber (result,
778 fname);
779 if (fnum < 0)
780 {
781 GNUNET_break (0);
782 return GNUNET_SYSERR;
783 }
784 if (PQgetisnull (result,
785 row,
786 fnum))
787 return GNUNET_NO;
788 GNUNET_assert (NULL != dst);
789 if (sizeof(struct GNUNET_TIME_Absolute) != *dst_size)
790 {
791 GNUNET_break (0);
792 return GNUNET_SYSERR;
793 }
794 if (sizeof(int64_t) !=
795 PQgetlength (result,
796 row,
797 fnum))
798 {
799 GNUNET_break (0);
800 return GNUNET_SYSERR;
801 }
802 res = (int64_t *) PQgetvalue (result,
803 row,
804 fnum);
805 if (INT64_MAX == GNUNET_ntohll ((uint64_t) *res))
806 {
808 }
809 else
810 {
811 abs.abs_value_us = GNUNET_ntohll ((uint64_t) *res);
812 if (0 != abs.abs_value_us % GNUNET_TIME_UNIT_SECONDS.rel_value_us)
813 {
814 /* timestamps must be multiple of seconds! */
815 GNUNET_break (0);
816 return GNUNET_SYSERR;
817 }
818 }
819 udst->abs_time = abs;
820 return GNUNET_OK;
821}
#define GNUNET_TIME_UNIT_SECONDS
One second.
Rounded time for timestamps used by GNUnet, in seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_SECONDS, res, and result.

Referenced by extract_timestamp_nbo(), and GNUNET_PQ_result_spec_timestamp().

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

◆ GNUNET_PQ_result_spec_timestamp()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp ( const char *  name,
struct GNUNET_TIME_Timestamp t 
)

Timestamp expected.

Parameters
namename of the field in the table
[out]twhere to store the result
Returns
array entry for the result specification to use

Definition at line 825 of file pq_result_helper.c.

827{
828 struct GNUNET_PQ_ResultSpec res = {
829 .conv = &extract_timestamp,
830 .dst = (void *) at,
831 .dst_size = sizeof(*at),
832 .fname = name
833 };
834
835 return res;
836}
static enum GNUNET_GenericReturnValue extract_timestamp(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_timestamp(), name, and res.

Here is the call graph for this function:

◆ extract_timestamp_nbo()

static enum GNUNET_GenericReturnValue extract_timestamp_nbo ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 853 of file pq_result_helper.c.

859{
860 struct GNUNET_TIME_TimestampNBO *udst = dst;
863
864 r = extract_timestamp (NULL,
865 result,
866 row,
867 fname,
868 dst_size,
869 &t);
870 if (GNUNET_OK != r)
871 return r;
873 return r;
874}
static struct GNUNET_SCHEDULER_Task * t
Main task.
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton(struct GNUNET_TIME_Timestamp t)
Convert timestamp to network byte order.
Definition: time.c:91
Time for timestamps used by GNUnet, in seconds and in network byte order.

References extract_timestamp(), GNUNET_OK, GNUNET_TIME_timestamp_hton(), result, and t.

Referenced by GNUNET_PQ_result_spec_timestamp_nbo().

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

◆ GNUNET_PQ_result_spec_timestamp_nbo()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp_nbo ( const char *  name,
struct GNUNET_TIME_TimestampNBO tn 
)

Timestamp expected.

Parameters
namename of the field in the table
[out]tnwhere to store the result
Returns
array entry for the result specification to use

Definition at line 878 of file pq_result_helper.c.

880{
881 struct GNUNET_PQ_ResultSpec res = {
882 .conv = &extract_timestamp_nbo,
883 .dst = (void *) at,
884 .dst_size = sizeof(*at),
885 .fname = name
886 };
887
888 return res;
889}
static enum GNUNET_GenericReturnValue extract_timestamp_nbo(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_timestamp_nbo(), name, and res.

Here is the call graph for this function:

◆ extract_uint16()

static enum GNUNET_GenericReturnValue extract_uint16 ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 906 of file pq_result_helper.c.

912{
913 uint16_t *udst = dst;
914 const uint16_t *res;
915 int fnum;
916
917 (void) cls;
918 fnum = PQfnumber (result,
919 fname);
920 if (fnum < 0)
921 {
922 GNUNET_break (0);
923 return GNUNET_SYSERR;
924 }
925 if (PQgetisnull (result,
926 row,
927 fnum))
928 return GNUNET_NO;
929 GNUNET_assert (NULL != dst);
930 if (sizeof(uint16_t) != *dst_size)
931 {
932 GNUNET_break (0);
933 return GNUNET_SYSERR;
934 }
935 if (sizeof(uint16_t) !=
936 PQgetlength (result,
937 row,
938 fnum))
939 {
940 GNUNET_break (0);
941 return GNUNET_SYSERR;
942 }
943 res = (uint16_t *) PQgetvalue (result,
944 row,
945 fnum);
946 *udst = ntohs (*res);
947 return GNUNET_OK;
948}

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_uint16().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_uint16()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint16 ( const char *  name,
uint16_t *  u16 
)

uint16_t expected.

Parameters
namename of the field in the table
[out]u16where to store the result
Returns
array entry for the result specification to use

Definition at line 952 of file pq_result_helper.c.

954{
955 struct GNUNET_PQ_ResultSpec res = {
956 .conv = &extract_uint16,
957 .dst = (void *) u16,
958 .dst_size = sizeof(*u16),
959 .fname = name
960 };
961
962 return res;
963}
static enum GNUNET_GenericReturnValue extract_uint16(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_uint16(), name, and res.

Here is the call graph for this function:

◆ extract_uint32()

static enum GNUNET_GenericReturnValue extract_uint32 ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 980 of file pq_result_helper.c.

986{
987 uint32_t *udst = dst;
988 const uint32_t *res;
989 int fnum;
990
991 (void) cls;
992 fnum = PQfnumber (result,
993 fname);
994 if (fnum < 0)
995 {
996 GNUNET_break (0);
997 return GNUNET_SYSERR;
998 }
999 if (PQgetisnull (result,
1000 row,
1001 fnum))
1002 return GNUNET_NO;
1003 GNUNET_assert (NULL != dst);
1004 if (sizeof(uint32_t) != *dst_size)
1005 {
1006 GNUNET_break (0);
1007 return GNUNET_SYSERR;
1008 }
1009 if (sizeof(uint32_t) !=
1010 PQgetlength (result,
1011 row,
1012 fnum))
1013 {
1014 GNUNET_break (0);
1015 return GNUNET_SYSERR;
1016 }
1017 res = (uint32_t *) PQgetvalue (result,
1018 row,
1019 fnum);
1020 *udst = ntohl (*res);
1021 return GNUNET_OK;
1022}

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_uint32().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_uint32()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint32 ( const char *  name,
uint32_t *  u32 
)

uint32_t expected.

Parameters
namename of the field in the table
[out]u32where to store the result
Returns
array entry for the result specification to use

Definition at line 1026 of file pq_result_helper.c.

1028{
1029 struct GNUNET_PQ_ResultSpec res = {
1030 .conv = &extract_uint32,
1031 .dst = (void *) u32,
1032 .dst_size = sizeof(*u32),
1033 .fname = name
1034 };
1035
1036 return res;
1037}
static enum GNUNET_GenericReturnValue extract_uint32(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_uint32(), name, and res.

Referenced by extract_result_cb(), GNUNET_PQ_get_oid_by_name(), handle_results(), parse_result_call_iterator(), postgres_plugin_del(), and process_result().

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

◆ extract_uint64()

static enum GNUNET_GenericReturnValue extract_uint64 ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 1054 of file pq_result_helper.c.

1060{
1061 uint64_t *udst = dst;
1062 const uint64_t *res;
1063 int fnum;
1064
1065 (void) cls;
1066 fnum = PQfnumber (result,
1067 fname);
1068 if (fnum < 0)
1069 {
1071 "Field %s missing in result\n",
1072 fname);
1073 GNUNET_break (0);
1074 return GNUNET_SYSERR;
1075 }
1076 if (PQgetisnull (result,
1077 row,
1078 fnum))
1079 return GNUNET_NO;
1080
1081 GNUNET_assert (NULL != dst);
1082 if (sizeof(uint64_t) != *dst_size)
1083 {
1084 GNUNET_break (0);
1085 return GNUNET_SYSERR;
1086 }
1087 if (sizeof(uint64_t) !=
1088 PQgetlength (result,
1089 row,
1090 fnum))
1091 {
1092 GNUNET_break (0);
1094 "Got length %u for field `%s'\n",
1095 PQgetlength (result,
1096 row,
1097 fnum),
1098 fname);
1099 return GNUNET_SYSERR;
1100 }
1101 res = (uint64_t *) PQgetvalue (result,
1102 row,
1103 fnum);
1104 *udst = GNUNET_ntohll (*res);
1105 return GNUNET_OK;
1106}

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_uint64().

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

◆ GNUNET_PQ_result_spec_uint64()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint64 ( const char *  name,
uint64_t *  u64 
)

uint64_t expected.

Parameters
namename of the field in the table
[out]u64where to store the result
Returns
array entry for the result specification to use

Definition at line 1110 of file pq_result_helper.c.

1112{
1113 struct GNUNET_PQ_ResultSpec res = {
1114 .conv = &extract_uint64,
1115 .dst = (void *) u64,
1116 .dst_size = sizeof(*u64),
1117 .fname = name
1118 };
1119
1120 return res;
1121}
static enum GNUNET_GenericReturnValue extract_uint64(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_uint64(), name, and res.

Referenced by parse_result_call_iterator(), postgres_plugin_del(), postgres_plugin_estimate_size(), and process_result().

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

◆ extract_int64()

static enum GNUNET_GenericReturnValue extract_int64 ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 1138 of file pq_result_helper.c.

1144{
1145 int64_t *udst = dst;
1146 const int64_t *res;
1147 int fnum;
1148
1149 (void) cls;
1150 fnum = PQfnumber (result,
1151 fname);
1152 if (fnum < 0)
1153 {
1155 "Field %s missing in result\n",
1156 fname);
1157 GNUNET_break (0);
1158 return GNUNET_SYSERR;
1159 }
1160 if (PQgetisnull (result,
1161 row,
1162 fnum))
1163 return GNUNET_NO;
1164
1165 GNUNET_assert (NULL != dst);
1166 if (sizeof(int64_t) != *dst_size)
1167 {
1168 GNUNET_break (0);
1169 return GNUNET_SYSERR;
1170 }
1171 if (sizeof(int64_t) !=
1172 PQgetlength (result,
1173 row,
1174 fnum))
1175 {
1176 GNUNET_break (0);
1178 "Got length %u for field `%s'\n",
1179 PQgetlength (result,
1180 row,
1181 fnum),
1182 fname);
1183 return GNUNET_SYSERR;
1184 }
1185 res = (int64_t *) PQgetvalue (result,
1186 row,
1187 fnum);
1188 *udst = GNUNET_ntohll (*res);
1189 return GNUNET_OK;
1190}

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, res, and result.

Referenced by GNUNET_PQ_result_spec_int64().

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

◆ GNUNET_PQ_result_spec_int64()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int64 ( const char *  name,
int64_t *  i64 
)

int64_t expected.

Parameters
namename of the field in the table
[out]i64where to store the result
Returns
array entry for the result specification to use

Definition at line 1194 of file pq_result_helper.c.

1196{
1197 struct GNUNET_PQ_ResultSpec res = {
1198 .conv = &extract_int64,
1199 .dst = (void *) i64,
1200 .dst_size = sizeof(*i64),
1201 .fname = name
1202 };
1203
1204 return res;
1205}
static enum GNUNET_GenericReturnValue extract_int64(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References GNUNET_PQ_ResultSpec::dst_size, extract_int64(), name, and res.

Here is the call graph for this function:

◆ extract_array_generic()

static enum GNUNET_GenericReturnValue extract_array_generic ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result as array of a specific type from row row.

The type information and optionally additional out-parameters are given in cls which is of type array_result_cls.

Parameters
clsclosure of type array_result_cls
resultwhere to extract data from
rowrow to extract data from
fnamename (or prefix) of the fields to extract 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 1248 of file pq_result_helper.c.

1255{
1256 const struct array_result_cls *info = cls;
1257 int data_sz;
1258 char *data;
1259 void *out = NULL;
1260 struct pq_array_header header;
1261 int col_num;
1262
1263 GNUNET_assert (NULL != dst);
1264 *((void **) dst) = NULL;
1265
1266 #define FAIL_IF(cond) \
1267 do { \
1268 if ((cond)) \
1269 { \
1270 GNUNET_break (! (cond)); \
1271 goto FAIL; \
1272 } \
1273 } while (0)
1274
1275 col_num = PQfnumber (result, fname);
1276 FAIL_IF (0 > col_num);
1277
1278 data_sz = PQgetlength (result, row, col_num);
1279 FAIL_IF (0 > data_sz);
1280 FAIL_IF (sizeof(header) > (size_t) data_sz);
1281
1282 data = PQgetvalue (result, row, col_num);
1283 FAIL_IF (NULL == data);
1284
1285 {
1286 struct pq_array_header *h =
1287 (struct pq_array_header *) data;
1288
1289 header.ndim = ntohl (h->ndim);
1290 header.has_null = ntohl (h->has_null);
1291 header.oid = ntohl (h->oid);
1292 header.dim = ntohl (h->dim);
1293 header.lbound = ntohl (h->lbound);
1294
1295 FAIL_IF (1 != header.ndim);
1296 FAIL_IF (INT_MAX <= header.dim);
1297 FAIL_IF (0 != header.has_null);
1298 FAIL_IF (1 != header.lbound);
1299 FAIL_IF (info->oid != header.oid);
1300 }
1301
1302 if (NULL != info->num)
1303 *info->num = header.dim;
1304
1305 {
1306 char *in = data + sizeof(header);
1307
1308 switch (info->typ)
1309 {
1310 case array_of_bool:
1311 if (NULL != dst_size)
1312 *dst_size = sizeof(bool) * (header.dim);
1313 out = GNUNET_new_array (header.dim, bool);
1314 *((void **) dst) = out;
1315 for (uint32_t i = 0; i < header.dim; i++)
1316 {
1317 size_t sz = ntohl (*(uint32_t *) in);
1318 FAIL_IF (sz != sizeof(bool));
1319 in += sizeof(uint32_t);
1320 *(bool *) out = *(bool *) in;
1321 in += sz;
1322 out += sz;
1323 }
1324 break;
1325
1326 case array_of_uint16:
1327 if (NULL != dst_size)
1328 *dst_size = sizeof(uint16_t) * (header.dim);
1329 out = GNUNET_new_array (header.dim, uint16_t);
1330 *((void **) dst) = out;
1331 for (uint32_t i = 0; i < header.dim; i++)
1332 {
1333 size_t sz = ntohl (*(uint32_t *) in);
1334 FAIL_IF (sz != sizeof(uint16_t));
1335 in += sizeof(uint32_t);
1336 *(uint16_t *) out = ntohs (*(uint16_t *) in);
1337 in += sz;
1338 out += sz;
1339 }
1340 break;
1341
1342 case array_of_uint32:
1343 if (NULL != dst_size)
1344 *dst_size = sizeof(uint32_t) * (header.dim);
1345 out = GNUNET_new_array (header.dim, uint32_t);
1346 *((void **) dst) = out;
1347 for (uint32_t i = 0; i < header.dim; i++)
1348 {
1349 size_t sz = ntohl (*(uint32_t *) in);
1350 FAIL_IF (sz != sizeof(uint32_t));
1351 in += sizeof(uint32_t);
1352 *(uint32_t *) out = ntohl (*(uint32_t *) in);
1353 in += sz;
1354 out += sz;
1355 }
1356 break;
1357
1358 case array_of_uint64:
1359 if (NULL != dst_size)
1360 *dst_size = sizeof(uint64_t) * (header.dim);
1361 out = GNUNET_new_array (header.dim, uint64_t);
1362 *((void **) dst) = out;
1363 for (uint32_t i = 0; i < header.dim; i++)
1364 {
1365 size_t sz = ntohl (*(uint32_t *) in);
1366 FAIL_IF (sz != sizeof(uint64_t));
1367 in += sizeof(uint32_t);
1368 *(uint64_t *) out = GNUNET_ntohll (*(uint64_t *) in);
1369 in += sz;
1370 out += sz;
1371 }
1372 break;
1373
1374 case array_of_abs_time:
1375 if (NULL != dst_size)
1376 *dst_size = sizeof(struct GNUNET_TIME_Absolute) * (header.dim);
1377 out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Absolute);
1378 *((void **) dst) = out;
1379 for (uint32_t i = 0; i < header.dim; i++)
1380 {
1381 size_t sz = ntohl (*(uint32_t *) in);
1382 FAIL_IF (sz != sizeof(uint64_t));
1383 in += sizeof(uint32_t);
1384 ((struct GNUNET_TIME_Absolute *) out)->abs_value_us =
1385 GNUNET_ntohll (*(uint64_t *) in);
1386 in += sz;
1387 out += sz;
1388 }
1389 break;
1390
1391 case array_of_rel_time:
1392 if (NULL != dst_size)
1393 *dst_size = sizeof(struct GNUNET_TIME_Relative) * (header.dim);
1394 out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Relative);
1395 *((void **) dst) = out;
1396 for (uint32_t i = 0; i < header.dim; i++)
1397 {
1398 size_t sz = ntohl (*(uint32_t *) in);
1399 FAIL_IF (sz != sizeof(uint64_t));
1400 in += sizeof(uint32_t);
1401 ((struct GNUNET_TIME_Relative *) out)->rel_value_us =
1402 GNUNET_ntohll (*(uint64_t *) in);
1403 in += sz;
1404 out += sz;
1405 }
1406 break;
1407
1408 case array_of_timestamp:
1409 if (NULL != dst_size)
1410 *dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (header.dim);
1411 out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Timestamp);
1412 *((void **) dst) = out;
1413 for (uint32_t i = 0; i < header.dim; i++)
1414 {
1415 size_t sz = ntohl (*(uint32_t *) in);
1416 FAIL_IF (sz != sizeof(uint64_t));
1417 in += sizeof(uint32_t);
1418 ((struct GNUNET_TIME_Timestamp *) out)->abs_time.abs_value_us =
1419 GNUNET_ntohll (*(uint64_t *) in);
1420 in += sz;
1421 out += sz;
1422 }
1423 break;
1424
1425 case array_of_byte:
1426 if (0 == info->same_size)
1427 *info->sizes = GNUNET_new_array (header.dim, size_t);
1428 /* fallthrough */
1429 case array_of_string:
1430 {
1431 size_t total = 0;
1432 bool is_string = (array_of_string == info->typ);
1433
1434 /* first, calculate total size required for allocation */
1435 {
1436 char *ptr = data + sizeof(header);
1437 for (uint32_t i = 0; i < header.dim; i++)
1438 {
1439 uint32_t sz;
1440
1441 sz = ntohl (*(uint32_t *) ptr);
1442 sz += is_string ? 1 : 0;
1443 total += sz;
1444 ptr += sizeof(uint32_t);
1445 ptr += sz;
1446
1447 if ((! is_string) &&
1448 (0 == info->same_size))
1449 (*info->sizes)[i] = sz;
1450
1451 FAIL_IF ((0 != info->same_size) &&
1452 (sz != info->same_size));
1453 FAIL_IF (total < sz);
1454 }
1455 }
1456
1457 if (NULL != dst_size)
1458 *dst_size = total;
1459
1460 FAIL_IF (0 == total);
1461 out = GNUNET_malloc (total);
1462
1463 *((void **) dst) = out;
1464
1465 /* copy data */
1466 for (uint32_t i = 0; i < header.dim; i++)
1467 {
1468 size_t sz = ntohl (*(uint32_t *) in);
1469 in += sizeof(uint32_t);
1470 GNUNET_memcpy (out, in, sz);
1471
1472 in += sz;
1473 out += sz;
1474 out += (array_of_string == info->typ) ? 1 : 0;
1475 }
1476 break;
1477 }
1478 default:
1479 FAIL_IF (1 != 0);
1480 }
1481 }
1482
1483 return GNUNET_OK;
1484
1485FAIL:
1486 GNUNET_free (*(void **) dst);
1487 return GNUNET_SYSERR;
1488 #undef FAIL_IF
1489}
#define INT_MAX
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static char * data
The data to insert into the dht.
#define info
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
@ array_of_byte
Definition: pq.h:137
@ array_of_uint32
Definition: pq.h:135
@ array_of_string
Definition: pq.h:138
@ array_of_rel_time
Definition: pq.h:140
@ array_of_uint16
Definition: pq.h:134
@ array_of_uint64
Definition: pq.h:136
@ array_of_abs_time
Definition: pq.h:139
@ array_of_timestamp
Definition: pq.h:141
@ array_of_bool
Definition: pq.h:133
#define FAIL_IF(cond)
Closure for the array result specifications.
the header for a postgresql array in binary format.
Definition: pq.h:151

References array_of_abs_time, array_of_bool, array_of_byte, array_of_rel_time, array_of_string, array_of_timestamp, array_of_uint16, array_of_uint32, array_of_uint64, data, pq_array_header::dim, FAIL, FAIL_IF, GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_new_array, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, h, pq_array_header::has_null, info, INT_MAX, pq_array_header::lbound, pq_array_header::ndim, pq_array_header::oid, and result.

Referenced by GNUNET_PQ_result_spec_array_abs_time(), GNUNET_PQ_result_spec_array_bool(), GNUNET_PQ_result_spec_array_fixed_size(), GNUNET_PQ_result_spec_array_rel_time(), GNUNET_PQ_result_spec_array_string(), GNUNET_PQ_result_spec_array_timestamp(), GNUNET_PQ_result_spec_array_uint16(), GNUNET_PQ_result_spec_array_uint32(), GNUNET_PQ_result_spec_array_uint64(), and GNUNET_PQ_result_spec_array_variable_size().

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

◆ array_cleanup()

static void array_cleanup ( void *  cls,
void *  rd 
)
static

Cleanup of the data and closure of an array spec.

Definition at line 1496 of file pq_result_helper.c.

1498{
1499
1500 struct array_result_cls *info = cls;
1501 void **dst = rd;
1502
1503 if ((array_of_byte == info->typ) &&
1504 (0 == info->same_size) &&
1505 (NULL != info->sizes))
1506 GNUNET_free (*(info->sizes));
1507
1508 GNUNET_free (cls);
1509 GNUNET_free (*dst);
1510 *dst = NULL;
1511}

References array_of_byte, GNUNET_free, info, and rd.

Referenced by GNUNET_PQ_result_spec_array_abs_time(), GNUNET_PQ_result_spec_array_bool(), GNUNET_PQ_result_spec_array_fixed_size(), GNUNET_PQ_result_spec_array_rel_time(), GNUNET_PQ_result_spec_array_string(), GNUNET_PQ_result_spec_array_timestamp(), GNUNET_PQ_result_spec_array_uint16(), GNUNET_PQ_result_spec_array_uint32(), GNUNET_PQ_result_spec_array_uint64(), and GNUNET_PQ_result_spec_array_variable_size().

Here is the caller graph for this function:

◆ GNUNET_PQ_result_spec_array_bool()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_bool ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
bool **  bools 
)

array of bool expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array bools.
[out]boolspointer to where to store the result, an array of num bool's. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1515 of file pq_result_helper.c.

1520{
1521 struct array_result_cls *info =
1523
1524 info->num = num;
1525 info->typ = array_of_bool;
1528 "bool",
1529 &info->oid));
1530
1531 struct GNUNET_PQ_ResultSpec res = {
1532 .conv = extract_array_generic,
1533 .cleaner = array_cleanup,
1534 .dst = (void *) dst,
1535 .fname = name,
1536 .cls = info
1537 };
1538 return res;
1539}
static struct GNUNET_FS_DirectoryBuilder * db
Definition: gnunet-search.c:97
enum GNUNET_GenericReturnValue GNUNET_PQ_get_oid_by_name(struct GNUNET_PQ_Context *db, const char *name, Oid *oid)
Returns the oid for a given datatype by name.
Definition: pq_connect.c:326
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_GenericReturnValue extract_array_generic(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result as array of a specific type from row row.
static void array_cleanup(void *cls, void *rd)
Cleanup of the data and closure of an array spec.
void * cls
Closure for conv and cleaner.

References array_cleanup(), array_of_bool, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_uint16()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint16 ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
uint16_t **  dst 
)

array of uint16_t expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u16s.
[out]dstpointer to where to store the an array of num uint16_t's. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1543 of file pq_result_helper.c.

1548{
1549 struct array_result_cls *info =
1551
1552 info->num = num;
1553 info->typ = array_of_uint16;
1556 "int2",
1557 &info->oid));
1558
1559 struct GNUNET_PQ_ResultSpec res = {
1560 .conv = extract_array_generic,
1561 .cleaner = array_cleanup,
1562 .dst = (void *) dst,
1563 .fname = name,
1564 .cls = info
1565 };
1566 return res;
1567}

References array_cleanup(), array_of_uint16, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_uint32()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint32 ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
uint32_t **  dst 
)

array of uint32_t expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u32s.
[out]dstpointer to where to store the array of num uint32_t's. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1571 of file pq_result_helper.c.

1576{
1577 struct array_result_cls *info =
1579
1580 info->num = num;
1581 info->typ = array_of_uint32;
1584 "int4",
1585 &info->oid));
1586
1587 struct GNUNET_PQ_ResultSpec res = {
1588 .conv = extract_array_generic,
1589 .cleaner = array_cleanup,
1590 .dst = (void *) dst,
1591 .fname = name,
1592 .cls = info
1593 };
1594 return res;
1595}

References array_cleanup(), array_of_uint32, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_uint64()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint64 ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
uint64_t **  dst 
)

array of uint64_t expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u64s.
[out]dstpointer to where to store the array of num uint64_t's. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1599 of file pq_result_helper.c.

1604{
1605 struct array_result_cls *info =
1607
1608 info->num = num;
1609 info->typ = array_of_uint64;
1612 "int8",
1613 &info->oid));
1614
1615 struct GNUNET_PQ_ResultSpec res = {
1616 .conv = extract_array_generic,
1617 .cleaner = array_cleanup,
1618 .dst = (void *) dst,
1619 .fname = name,
1620 .cls = info
1621 };
1622 return res;
1623}

References array_cleanup(), array_of_uint64, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_abs_time()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_abs_time ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
struct GNUNET_TIME_Absolute **  dst 
)

array of absolute time expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u64s.
[out]dstpointer to where to store the array of num absolute time. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1627 of file pq_result_helper.c.

1632{
1633 struct array_result_cls *info =
1635
1636 info->num = num;
1637 info->typ = array_of_abs_time;
1640 "int8",
1641 &info->oid));
1642
1643 struct GNUNET_PQ_ResultSpec res = {
1644 .conv = extract_array_generic,
1645 .cleaner = array_cleanup,
1646 .dst = (void *) dst,
1647 .fname = name,
1648 .cls = info
1649 };
1650 return res;
1651}

References array_cleanup(), array_of_abs_time, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_rel_time()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_rel_time ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
struct GNUNET_TIME_Relative **  dst 
)

array of relative time expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u64s.
[out]dstpointer to where to store the array of num relate time. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1655 of file pq_result_helper.c.

1660{
1661 struct array_result_cls *info =
1663
1664 info->num = num;
1665 info->typ = array_of_rel_time;
1668 "int8",
1669 &info->oid));
1670
1671 struct GNUNET_PQ_ResultSpec res = {
1672 .conv = extract_array_generic,
1673 .cleaner = array_cleanup,
1674 .dst = (void *) dst,
1675 .fname = name,
1676 .cls = info
1677 };
1678 return res;
1679}

References array_cleanup(), array_of_rel_time, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_timestamp()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_timestamp ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
struct GNUNET_TIME_Timestamp **  dst 
)

array of relative time expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements in the array u64s.
[out]dstpointer to where to store the array of num timestamps. Allocated by the function, MUST be freed with GNUNET_free.
Returns
array entry for the result specification to use

Definition at line 1683 of file pq_result_helper.c.

1688{
1689 struct array_result_cls *info =
1691
1692 info->num = num;
1693 info->typ = array_of_timestamp;
1696 "int8",
1697 &info->oid));
1698
1699 struct GNUNET_PQ_ResultSpec res = {
1700 .conv = extract_array_generic,
1701 .cleaner = array_cleanup,
1702 .dst = (void *) dst,
1703 .fname = name,
1704 .cls = info
1705 };
1706 return res;
1707}

References array_cleanup(), array_of_timestamp, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_variable_size()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_variable_size ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
size_t **  sizes,
void **  dst 
)

Array of variable-size result expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements
[out]sizeswhere to store the num size's of byte-buffers in dst
[out]dstwhere to store the continuous array of num byte-buffers , allocated
Returns
array entry for the result specification to use

Definition at line 1711 of file pq_result_helper.c.

1717{
1718 struct array_result_cls *info =
1720
1721 info->num = num;
1722 info->sizes = sizes;
1723 info->typ = array_of_byte;
1726 "bytea",
1727 &info->oid));
1728
1729 struct GNUNET_PQ_ResultSpec res = {
1730 .conv = extract_array_generic,
1731 .cleaner = array_cleanup,
1732 .dst = (void *) dst,
1733 .fname = name,
1734 .cls = info
1735 };
1736 return res;
1737}

References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, res, and array_result_cls::sizes.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_fixed_size()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_fixed_size ( struct GNUNET_PQ_Context db,
const char *  name,
size_t  size,
size_t *  num,
void **  dst 
)

Array of fixed-size result expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
sizenumber of bytes expected in each element of dst
[out]numwhere to store the number of elements
[out]dstwhere to store the results, an continuous array of fixed-size elements
Returns
array entry for the result specification to use

Definition at line 1741 of file pq_result_helper.c.

1747{
1748 struct array_result_cls *info =
1750
1751 info->num = num;
1752 info->same_size = size;
1753 info->typ = array_of_byte;
1756 "bytea",
1757 &info->oid));
1758
1759 struct GNUNET_PQ_ResultSpec res = {
1760 .conv = extract_array_generic,
1761 .cleaner = array_cleanup,
1762 .dst = (void *) dst,
1763 .fname = name,
1764 .cls = info
1765 };
1766 return res;
1767}
static unsigned int size
Size of the "table".
Definition: peer.c:68

References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, res, and size.

Here is the call graph for this function:

◆ GNUNET_PQ_result_spec_array_string()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_string ( struct GNUNET_PQ_Context db,
const char *  name,
size_t *  num,
char **  dst 
)

Array of 0-terminated strings expected.

Parameters
dbDatabase context, needed for OID lookup for the correct type
namename of the field in the table
[out]numwhere to store the number of elements
[out]dstwhere to store the allocated continous array of num 0-terminated strings
Returns
array entry for the result specification to use

Definition at line 1771 of file pq_result_helper.c.

1776{
1777 struct array_result_cls *info =
1779
1780 info->num = num;
1781 info->typ = array_of_string;
1784 "text",
1785 &info->oid));
1786
1787 struct GNUNET_PQ_ResultSpec res = {
1788 .conv = extract_array_generic,
1789 .cleaner = array_cleanup,
1790 .dst = (void *) dst,
1791 .fname = name,
1792 .cls = info
1793 };
1794 return res;
1795}

References array_cleanup(), array_of_string, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.

Here is the call graph for this function:

◆ extract_blind_sign_pub()

static enum GNUNET_GenericReturnValue extract_blind_sign_pub ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowthe row to extract data from
fnamename (or prefix) of the fields to extract 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 1812 of file pq_result_helper.c.

1818{
1819 struct GNUNET_CRYPTO_BlindSignPublicKey *bpk = dst;
1820 size_t len;
1821 const char *res;
1822 int fnum;
1823 uint32_t be;
1824
1825 (void) cls;
1826 (void) dst_size;
1827 fnum = PQfnumber (result,
1828 fname);
1829 if (fnum < 0)
1830 {
1831 GNUNET_break (0);
1832 return GNUNET_SYSERR;
1833 }
1834 if (PQgetisnull (result,
1835 row,
1836 fnum))
1837 return GNUNET_NO;
1838
1839 /* if a field is null, continue but
1840 * remember that we now return a different result */
1841 len = PQgetlength (result,
1842 row,
1843 fnum);
1844 res = PQgetvalue (result,
1845 row,
1846 fnum);
1847 if (len < sizeof (be))
1848 {
1849 GNUNET_break (0);
1850 return GNUNET_SYSERR;
1851 }
1852 GNUNET_memcpy (&be,
1853 res,
1854 sizeof (be));
1855 res += sizeof (be);
1856 len -= sizeof (be);
1858 bpk->cipher = ntohl (be);
1859 bpk->rc = 1;
1860 switch (bpk->cipher)
1861 {
1863 break;
1867 len);
1868 if (NULL == bpk->details.rsa_public_key)
1869 {
1870 GNUNET_break (0);
1871 GNUNET_free (bpk);
1872 return GNUNET_SYSERR;
1873 }
1875 len,
1876 &bpk->pub_key_hash);
1877 return GNUNET_OK;
1879 if (sizeof (bpk->details.cs_public_key) != len)
1880 {
1881 GNUNET_break (0);
1882 GNUNET_free (bpk);
1883 return GNUNET_SYSERR;
1884 }
1886 res,
1887 len);
1889 len,
1890 &bpk->pub_key_hash);
1891 return GNUNET_OK;
1892 }
1893 GNUNET_break (0);
1894 GNUNET_free (bpk);
1895 return GNUNET_SYSERR;
1896}
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@16 details
Details, depending on cipher.
unsigned int rc
Reference counter.
struct GNUNET_HashCode pub_key_hash
Hash of the public key.
struct GNUNET_CRYPTO_CsPublicKey cs_public_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
struct GNUNET_CRYPTO_RsaPublicKey * rsa_public_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.

References GNUNET_CRYPTO_BlindSignPublicKey::cipher, GNUNET_CRYPTO_BlindSignPublicKey::cs_public_key, GNUNET_CRYPTO_BlindSignPublicKey::details, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_rsa_public_key_decode(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_CRYPTO_BlindSignPublicKey::pub_key_hash, GNUNET_CRYPTO_BlindSignPublicKey::rc, res, result, and GNUNET_CRYPTO_BlindSignPublicKey::rsa_public_key.

Referenced by GNUNET_PQ_result_spec_blind_sign_pub().

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

◆ clean_blind_sign_pub()

static void clean_blind_sign_pub ( void *  cls,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 1907 of file pq_result_helper.c.

1909{
1911
1912 (void) cls;
1914 pub = NULL;
1915}
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
void GNUNET_CRYPTO_blind_sign_pub_decref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Decrement reference counter of a bsign_pub, and free it if it reaches zero.

References GNUNET_CRYPTO_blind_sign_pub_decref(), pub, and rd.

Referenced by GNUNET_PQ_result_spec_blind_sign_pub().

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

◆ GNUNET_PQ_result_spec_blind_sign_pub()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_pub ( const char *  name,
struct GNUNET_CRYPTO_BlindSignPublicKey public_key 
)

Blind sign public key expected.

Parameters
namename of the field in the table
[out]public_keywhere to store the denomination signature
Returns
array entry for the result specification to use

Definition at line 1919 of file pq_result_helper.c.

1921{
1922 struct GNUNET_PQ_ResultSpec res = {
1923 .conv = &extract_blind_sign_pub,
1924 .cleaner = &clean_blind_sign_pub,
1925 .dst = (void *) pub,
1926 .fname = name
1927 };
1928
1929 return res;
1930}
static void clean_blind_sign_pub(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
static enum GNUNET_GenericReturnValue extract_blind_sign_pub(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.

References clean_blind_sign_pub(), extract_blind_sign_pub(), GNUNET_PQ_ResultSpec::fname, name, pub, and res.

Here is the call graph for this function:

◆ extract_blind_sign_priv()

static enum GNUNET_GenericReturnValue extract_blind_sign_priv ( void *  cls,
PGresult *  result,
int  row,
const char *  fname,
size_t *  dst_size,
void *  dst 
)
static

Extract data from a Postgres database result at row row.

Parameters
clsclosure
resultwhere to extract data from
rowthe row to extract data from
fnamename (or prefix) of the fields to extract 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 1947 of file pq_result_helper.c.

1953{
1954 struct GNUNET_CRYPTO_BlindSignPrivateKey *bpk = dst;
1955 size_t len;
1956 const char *res;
1957 int fnum;
1958 uint32_t be;
1959
1960 (void) cls;
1961 (void) dst_size;
1962 fnum = PQfnumber (result,
1963 fname);
1964 if (fnum < 0)
1965 {
1966 GNUNET_break (0);
1967 return GNUNET_SYSERR;
1968 }
1969 if (PQgetisnull (result,
1970 row,
1971 fnum))
1972 return GNUNET_NO;
1973
1974 /* if a field is null, continue but
1975 * remember that we now return a different result */
1976 len = PQgetlength (result,
1977 row,
1978 fnum);
1979 res = PQgetvalue (result,
1980 row,
1981 fnum);
1982 if (len < sizeof (be))
1983 {
1984 GNUNET_break (0);
1985 return GNUNET_SYSERR;
1986 }
1987 GNUNET_memcpy (&be,
1988 res,
1989 sizeof (be));
1990 res += sizeof (be);
1991 len -= sizeof (be);
1993 bpk->cipher = ntohl (be);
1994 bpk->rc = 1;
1995 switch (bpk->cipher)
1996 {
1998 break;
2002 len);
2003 if (NULL == bpk->details.rsa_private_key)
2004 {
2005 GNUNET_break (0);
2006 GNUNET_free (bpk);
2007 return GNUNET_SYSERR;
2008 }
2009 return GNUNET_OK;
2011 if (sizeof (bpk->details.cs_private_key) != len)
2012 {
2013 GNUNET_break (0);
2014 GNUNET_free (bpk);
2015 return GNUNET_SYSERR;
2016 }
2018 res,
2019 len);
2020 return GNUNET_OK;
2021 }
2022 GNUNET_break (0);
2023 GNUNET_free (bpk);
2024 return GNUNET_SYSERR;
2025}
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_decode(const void *buf, size_t buf_size)
Decode the private key from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:204
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@17 details
Details, depending on cipher.

References GNUNET_CRYPTO_BlindSignPrivateKey::cipher, GNUNET_CRYPTO_BlindSignPrivateKey::cs_private_key, GNUNET_CRYPTO_BlindSignPrivateKey::details, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_rsa_private_key_decode(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_CRYPTO_BlindSignPrivateKey::rc, res, result, and GNUNET_CRYPTO_BlindSignPrivateKey::rsa_private_key.

Referenced by GNUNET_PQ_result_spec_blind_sign_priv().

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

◆ clean_blind_sign_priv()

static void clean_blind_sign_priv ( void *  cls,
void *  rd 
)
static

Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

Parameters
clsclosure
rdresult data to clean up

Definition at line 2036 of file pq_result_helper.c.

2038{
2040
2041 (void) cls;
2043 pub = NULL;
2044}

References GNUNET_CRYPTO_blind_sign_pub_decref(), pub, and rd.

Referenced by GNUNET_PQ_result_spec_blind_sign_priv().

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

◆ GNUNET_PQ_result_spec_blind_sign_priv()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_priv ( const char *  name,
struct GNUNET_CRYPTO_BlindSignPrivateKey private_key 
)

Blind sign private key expected.

Parameters
namename of the field in the table
[out]private_keywhere to store the denomination signature
Returns
array entry for the result specification to use

Definition at line 2048 of file pq_result_helper.c.

2050{
2051 struct GNUNET_PQ_ResultSpec res = {
2052 .conv = &extract_blind_sign_priv,
2053 .cleaner = &clean_blind_sign_priv,
2054 .dst = (void *) priv,
2055 .fname = name
2056 };
2057
2058 return res;
2059}
static enum GNUNET_GenericReturnValue extract_blind_sign_priv(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_blind_sign_priv(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

References clean_blind_sign_priv(), extract_blind_sign_priv(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function: