GNUnet 0.29.1-7-g14698f198
 
Loading...
Searching...
No Matches
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)
 
#define HANDLE_ELEMENT(typ, conv, access)
 
#define HANDLE_ARRAY(typ, conv, access)
 
#define DEREF(typ, conv)    *(typ *) out = conv (*(typ *) in)
 
#define ACCESS_ABS(typ, conv)    ((typ *) out)->abs_value_us = conv (*(uint64_t *) in)
 
#define ACCESS_REL(typ, conv)    ((typ *) out)->rel_value_us = conv (*(uint64_t *) in)
 
#define ACCESS_TSTMP(typ, conv)    ((typ *) out)->abs_time.abs_value_us = conv (*(uint64_t *) in)
 

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.
 
static void clean_varsize_blob (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr)
 Variable-size result expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size)
 Fixed-size result expected.
 
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.
 
static void clean_rsa_public_key (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_RsaPublicKey **rsa)
 RSA public key expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
 RSA signature expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string (const char *name, char **dst)
 0-terminated string expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_bool (const char *name, bool *dst)
 boolean expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_relative_time (const char *name, struct GNUNET_TIME_Relative *rt)
 Relative time expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at)
 Absolute time expected.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
 Absolute time expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp (const char *name, struct GNUNET_TIME_Timestamp *at)
 Timestamp expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO *at)
 Timestamp expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16)
 uint16_t expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32)
 uint32_t expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64)
 uint64_t expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int64 (const char *name, int64_t *i64)
 int64_t expected.
 
static enum GNUNET_GenericReturnValue extract_int16 (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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int16 (const char *name, int16_t *i16)
 int16_t expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_allow_nulls (struct GNUNET_PQ_ResultSpec rs, bool **is_nulls)
 Allow NULL values in an array to be found in the database for the given value.
 
static void array_cleanup (void *cls, void *rd)
 Cleanup of the data and closure of an array spec.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_int16 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, int16_t **dst)
 array of int16_t expected.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static void clean_blind_sign_pub (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_pub (const char *name, struct GNUNET_CRYPTO_BlindSignPublicKey **pub)
 Blind sign public key expected.
 
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.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_priv (const char *name, struct GNUNET_CRYPTO_BlindSignPrivateKey **priv)
 Blind sign private key expected.
 
static enum GNUNET_GenericReturnValue extract_blinded_sig (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_blinded_sig (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blinded_sig (const char *name, struct GNUNET_CRYPTO_BlindedSignature **b_sig)
 Blinded signature expected.
 
static enum GNUNET_GenericReturnValue extract_unblinded_sig (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_unblinded_sig (void *cls, void *rd)
 Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
 
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_unblinded_sig (const char *name, struct GNUNET_CRYPTO_UnblindedSignature **ub_sig)
 Unblinded signature expected.
 

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

◆ HANDLE_ELEMENT

#define HANDLE_ELEMENT (   typ,
  conv,
  access 
)
Value:
do { \
int32_t sz = ntohl (*(int32_t *) in); \
\
in += sizeof(uint32_t); \
if (-1 != sz) \
{ \
FAIL_IF (sz != sizeof(typ)); \
access (typ, conv); \
in += sz; \
} \
else \
{ \
FAIL_IF (! info->allow_nulls); \
(*info->is_nulls)[i] = true; \
} \
\
out += sizeof(typ); \
} while (0)
static GstElement * conv
#define info

◆ HANDLE_ARRAY

#define HANDLE_ARRAY (   typ,
  conv,
  access 
)
Value:
do { \
if (NULL != dst_size) \
*dst_size = sizeof(typ) *(header.dim); \
out = GNUNET_new_array (header.dim, typ); \
*((void **) dst) = out; \
for (uint32_t i = 0; i < header.dim; i++) \
{ \
HANDLE_ELEMENT (typ, conv, access); \
} \
} while (0)
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.

◆ DEREF

#define DEREF (   typ,
  conv 
)     *(typ *) out = conv (*(typ *) in)

◆ ACCESS_ABS

#define ACCESS_ABS (   typ,
  conv 
)     ((typ *) out)->abs_value_us = conv (*(uint64_t *) in)

◆ ACCESS_REL

#define ACCESS_REL (   typ,
  conv 
)     ((typ *) out)->rel_value_us = conv (*(uint64_t *) in)

◆ ACCESS_TSTMP

#define ACCESS_TSTMP (   typ,
  conv 
)     ((typ *) out)->abs_time.abs_value_us = conv (*(uint64_t *) in)

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 34 of file pq_result_helper.c.

36{
37 struct GNUNET_PQ_ResultSpec rsr;
38
39 rsr = rs;
40 rsr.is_nullable = true;
41 rsr.is_null = is_null;
42 return rsr;
43}
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 54 of file pq_result_helper.c.

56{
57 void **dst = rd;
58
59 (void) cls;
60 if (NULL != *dst)
61 {
62 GNUNET_free (*dst);
63 *dst = NULL;
64 }
65}
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 82 of file pq_result_helper.c.

88{
89 size_t len;
90 const char *res;
91 void *idst;
92 int fnum;
93
94 (void) cls;
95 *dst_size = 0;
96 *((void **) dst) = NULL;
97
98 fnum = PQfnumber (result,
99 fname);
100 if (fnum < 0)
101 {
102 GNUNET_break (0);
103 return GNUNET_SYSERR;
104 }
105 if (PQgetisnull (result,
106 row,
107 fnum))
108 return GNUNET_NO;
109 /* if a field is null, continue but
110 * remember that we now return a different result */
111 len = PQgetlength (result,
112 row,
113 fnum);
114 res = PQgetvalue (result,
115 row,
116 fnum);
117 GNUNET_assert (NULL != res);
118 *dst_size = len;
119 idst = GNUNET_malloc (len);
120 *((void **) dst) = idst;
121 GNUNET_memcpy (idst,
122 res,
123 len);
124 return GNUNET_OK;
125}
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 129 of file pq_result_helper.c.

132{
133 struct GNUNET_PQ_ResultSpec res = {
135 .cleaner = &clean_varsize_blob,
136 .dst = (void *) (dst),
137 .fname = name,
138 .result_size = sptr
139 };
140
141 return res;
142}
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.
GNUNET_PQ_ResultConverter conv
What is the format of the result?

References clean_varsize_blob(), GNUNET_PQ_ResultSpec::conv, 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 159 of file pq_result_helper.c.

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

215{
216 struct GNUNET_PQ_ResultSpec res = {
218 .dst = (dst),
220 .fname = name
221 };
222
223 return res;
224}
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::conv, 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 241 of file pq_result_helper.c.

247{
248 struct GNUNET_CRYPTO_RsaPublicKey **pk = dst;
249 size_t len;
250 const char *res;
251 int fnum;
252
253 (void) cls;
254 (void) dst_size;
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_BlindablePrivateKey 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 = {
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(), GNUNET_PQ_ResultSpec::conv, 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 (void) dst_size;
352 *sig = NULL;
353 fnum = PQfnumber (result,
354 fname);
355 if (fnum < 0)
356 {
357 GNUNET_break (0);
358 return GNUNET_SYSERR;
359 }
360 if (PQgetisnull (result,
361 row,
362 fnum))
363 return GNUNET_NO;
364 /* if a field is null, continue but
365 * remember that we now return a different result */
366 len = PQgetlength (result,
367 row,
368 fnum);
369 res = PQgetvalue (result,
370 row,
371 fnum);
373 len);
374 if (NULL == *sig)
375 {
376 GNUNET_break (0);
377 return GNUNET_SYSERR;
378 }
379 return GNUNET_OK;
380}
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.

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 391 of file pq_result_helper.c.

393{
394 struct GNUNET_CRYPTO_RsaSignature **sig = rd;
395
396 (void) cls;
397 if (NULL != *sig)
398 {
400 *sig = NULL;
401 }
402}
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.

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 406 of file pq_result_helper.c.

408{
409 struct GNUNET_PQ_ResultSpec res = {
411 .cleaner = &clean_rsa_signature,
412 .dst = (void *) sig,
413 .fname = name
414 };
415
416 return res;
417}
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(), GNUNET_PQ_ResultSpec::conv, 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 434 of file pq_result_helper.c.

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

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

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 487 of file pq_result_helper.c.

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

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

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 502 of file pq_result_helper.c.

504{
505 struct GNUNET_PQ_ResultSpec res = {
507 .cleaner = &clean_string,
508 .dst = (void *) dst,
509 .fname = (name)
510 };
511
512 return res;
513}
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::conv, GNUNET_PQ_ResultSpec::dst, extract_string(), GNUNET_PQ_ResultSpec::fname, name, and res.

Referenced by check_patch_applied(), 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 530 of file pq_result_helper.c.

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

References GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, 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 574 of file pq_result_helper.c.

576{
577 struct GNUNET_PQ_ResultSpec res = {
578 .conv = &extract_bool,
579 .dst = (void *) dst,
580 .fname = name
581 };
582
583 return res;
584}
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::conv, 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 601 of file pq_result_helper.c.

607{
608 struct GNUNET_TIME_Relative *udst = dst;
609 const int64_t *res;
610 int fnum;
611
612 (void) cls;
613 fnum = PQfnumber (result,
614 fname);
615 if (fnum < 0)
616 {
617 GNUNET_break (0);
618 return GNUNET_SYSERR;
619 }
620 if (PQgetisnull (result,
621 row,
622 fnum))
623 return GNUNET_NO;
624 GNUNET_assert (NULL != dst);
625 if (sizeof(struct GNUNET_TIME_Relative) != *dst_size)
626 {
627 GNUNET_break (0);
628 return GNUNET_SYSERR;
629 }
630 if (sizeof(int64_t) !=
631 PQgetlength (result,
632 row,
633 fnum))
634 {
635 GNUNET_break (0);
636 return GNUNET_SYSERR;
637 }
638 res = (int64_t *) PQgetvalue (result,
639 row,
640 fnum);
641 if (INT64_MAX == GNUNET_ntohll ((uint64_t) *res))
643 else
644 udst->rel_value_us = GNUNET_ntohll ((uint64_t) *res);
645 return GNUNET_OK;
646}
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#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 650 of file pq_result_helper.c.

652{
653 struct GNUNET_PQ_ResultSpec res = {
655 .dst = (void *) rt,
656 .dst_size = sizeof(*rt),
657 .fname = name
658 };
659
660 return res;
661}
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::conv, 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 678 of file pq_result_helper.c.

684{
685 struct GNUNET_TIME_Absolute *udst = dst;
686 const int64_t *res;
687 int fnum;
688
689 (void) cls;
690 fnum = PQfnumber (result,
691 fname);
692 if (fnum < 0)
693 {
694 GNUNET_break (0);
695 return GNUNET_SYSERR;
696 }
697 if (PQgetisnull (result,
698 row,
699 fnum))
700 return GNUNET_NO;
701 GNUNET_assert (NULL != dst);
702 if (sizeof(struct GNUNET_TIME_Absolute) != *dst_size)
703 {
704 GNUNET_break (0);
705 return GNUNET_SYSERR;
706 }
707 if (sizeof(int64_t) !=
708 PQgetlength (result,
709 row,
710 fnum))
711 {
712 GNUNET_break (0);
713 return GNUNET_SYSERR;
714 }
715 res = (int64_t *) PQgetvalue (result,
716 row,
717 fnum);
718 if (INT64_MAX == GNUNET_ntohll ((uint64_t) *res))
720 else
721 udst->abs_value_us = GNUNET_ntohll ((uint64_t) *res);
722 return GNUNET_OK;
723}
#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 727 of file pq_result_helper.c.

729{
730 struct GNUNET_PQ_ResultSpec res = {
732 .dst = (void *) at,
733 .dst_size = sizeof(*at),
734 .fname = name
735 };
736
737 return res;
738}
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::conv, 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 742 of file pq_result_helper.c.

744{
747 &at->abs_value_us__);
748
749 return res;
750}
#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 767 of file pq_result_helper.c.

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

830{
831 struct GNUNET_PQ_ResultSpec res = {
833 .dst = (void *) at,
834 .dst_size = sizeof(*at),
835 .fname = name
836 };
837
838 return res;
839}
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::conv, 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 856 of file pq_result_helper.c.

862{
863 struct GNUNET_TIME_TimestampNBO *udst = dst;
866
867 (void) cls;
868 r = extract_timestamp (NULL,
869 result,
870 row,
871 fname,
872 dst_size,
873 &t);
874 if (GNUNET_OK != r)
875 return r;
877 return r;
878}
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 882 of file pq_result_helper.c.

884{
885 struct GNUNET_PQ_ResultSpec res = {
887 .dst = (void *) at,
888 .dst_size = sizeof(*at),
889 .fname = name
890 };
891
892 return res;
893}
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::conv, 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 910 of file pq_result_helper.c.

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

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 956 of file pq_result_helper.c.

958{
959 struct GNUNET_PQ_ResultSpec res = {
961 .dst = (void *) u16,
962 .dst_size = sizeof(*u16),
963 .fname = name
964 };
965
966 return res;
967}
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::conv, 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 984 of file pq_result_helper.c.

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

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 1030 of file pq_result_helper.c.

1032{
1033 struct GNUNET_PQ_ResultSpec res = {
1034 .conv = &extract_uint32,
1035 .dst = (void *) u32,
1036 .dst_size = sizeof(*u32),
1037 .fname = name
1038 };
1039
1040 return res;
1041}
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::conv, 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 1058 of file pq_result_helper.c.

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

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 1114 of file pq_result_helper.c.

1116{
1117 struct GNUNET_PQ_ResultSpec res = {
1118 .conv = &extract_uint64,
1119 .dst = (void *) u64,
1120 .dst_size = sizeof(*u64),
1121 .fname = name
1122 };
1123
1124 return res;
1125}
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::conv, 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 1142 of file pq_result_helper.c.

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

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 1198 of file pq_result_helper.c.

1200{
1201 struct GNUNET_PQ_ResultSpec res = {
1202 .conv = &extract_int64,
1203 .dst = (void *) i64,
1204 .dst_size = sizeof(*i64),
1205 .fname = name
1206 };
1207
1208 return res;
1209}
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::conv, GNUNET_PQ_ResultSpec::dst_size, extract_int64(), name, and res.

Here is the call graph for this function:

◆ extract_int16()

static enum GNUNET_GenericReturnValue extract_int16 ( 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 1226 of file pq_result_helper.c.

1232{
1233 int16_t *udst = dst;
1234 const int16_t *res;
1235 int fnum;
1236
1237 (void) cls;
1238 fnum = PQfnumber (result,
1239 fname);
1240 if (fnum < 0)
1241 {
1243 "Field %s missing in result\n",
1244 fname);
1245 GNUNET_break (0);
1246 return GNUNET_SYSERR;
1247 }
1248 if (PQgetisnull (result,
1249 row,
1250 fnum))
1251 return GNUNET_NO;
1252
1253 GNUNET_assert (NULL != dst);
1254 if (sizeof(int16_t) != *dst_size)
1255 {
1256 GNUNET_break (0);
1257 return GNUNET_SYSERR;
1258 }
1259 if (sizeof(int16_t) !=
1260 PQgetlength (result,
1261 row,
1262 fnum))
1263 {
1264 GNUNET_break (0);
1266 "Got length %u for field `%s'\n",
1267 PQgetlength (result,
1268 row,
1269 fnum),
1270 fname);
1271 return GNUNET_SYSERR;
1272 }
1273 res = (int16_t *) PQgetvalue (result,
1274 row,
1275 fnum);
1276 *udst = GNUNET_ntohll (*res);
1277 return GNUNET_OK;
1278}

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_int16().

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

◆ GNUNET_PQ_result_spec_int16()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int16 ( const char *  name,
int16_t *  i16 
)

int16_t expected.

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

Definition at line 1282 of file pq_result_helper.c.

1284{
1285 struct GNUNET_PQ_ResultSpec res = {
1286 .conv = &extract_int16,
1287 .dst = (void *) i16,
1288 .dst_size = sizeof(*i16),
1289 .fname = name
1290 };
1291
1292 return res;
1293}
static enum GNUNET_GenericReturnValue extract_int16(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::conv, GNUNET_PQ_ResultSpec::dst_size, extract_int16(), 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)

The sizes of the elements in the input. A NULL element will be indicated in the input by a size of -1. However, we will then use an element size of either 0 (for variable sized data) or info->same_size (for fixed sized data).

The amounts of bytes to advance the in-pointer after the encoded size of an element. If the element is NULL (indicated by a size of -1), the value will be 0, independent of the corresponding value of elem_sz.

Definition at line 1344 of file pq_result_helper.c.

1351{
1352 const struct array_result_cls *info = cls;
1353 int data_sz;
1354 char *data;
1355 void *out = NULL;
1356 struct pq_array_header header;
1357 int col_num;
1358
1359 GNUNET_assert (NULL != dst);
1360 *((void **) dst) = NULL;
1361
1362#define FAIL_IF(cond) \
1363 do { \
1364 if ((cond)) \
1365 { \
1366 GNUNET_break (! (cond)); \
1367 goto FAIL; \
1368 } \
1369 } while (0)
1370
1371 col_num = PQfnumber (result, fname);
1372 FAIL_IF (0 > col_num);
1373
1374 data_sz = PQgetlength (result, row, col_num);
1375 FAIL_IF (0 > data_sz);
1376
1377 /* Report if this field is empty */
1378 if (0 == (size_t) data_sz)
1379 return GNUNET_NO;
1380
1381 data = PQgetvalue (result, row, col_num);
1382
1383 if (sizeof(header) > (size_t) data_sz)
1384 {
1385 uint32_t ndim;
1386
1387 /* data_sz is shorter than header if the
1388 array length is 0, in which case ndim is 0! */
1389 FAIL_IF (sizeof(uint32_t) > (size_t) data_sz);
1390 memcpy (&ndim,
1391 data,
1392 sizeof (ndim));
1393 FAIL_IF (0 != ndim);
1394 *info->num = 0;
1395 return GNUNET_OK;
1396 }
1397 FAIL_IF (sizeof(header) > (size_t) data_sz);
1398 FAIL_IF (NULL == data);
1399
1400 {
1401 struct pq_array_header *h =
1402 (struct pq_array_header *) data;
1403
1404 header.ndim = ntohl (h->ndim);
1405 header.has_nulls = ntohl (h->has_nulls);
1406 header.oid = ntohl (h->oid);
1407 header.dim = ntohl (h->dim);
1408 header.lbound = ntohl (h->lbound);
1409
1410 FAIL_IF (1 != header.ndim);
1411 FAIL_IF (INT_MAX <= header.dim);
1412 FAIL_IF ((0 != header.has_nulls) && ! info->allow_nulls);
1413 FAIL_IF (1 != header.lbound);
1414 FAIL_IF (info->oid != header.oid);
1415 }
1416
1417 if (NULL != info->num)
1418 *info->num = header.dim;
1419
1420 /* Prepare the array of bools, marking NULL elements */
1421 if (info->allow_nulls)
1422 *info->is_nulls = GNUNET_new_array (header.dim, bool);
1423
1424 {
1425 char *in = data + sizeof(header);
1426
1427#define HANDLE_ELEMENT(typ, conv, access) \
1428 do { \
1429 int32_t sz = ntohl (*(int32_t *) in); \
1430\
1431 in += sizeof(uint32_t); \
1432 if (-1 != sz) \
1433 { \
1434 FAIL_IF (sz != sizeof(typ)); \
1435 access (typ, conv); \
1436 in += sz; \
1437 } \
1438 else \
1439 { \
1440 FAIL_IF (! info->allow_nulls); \
1441 (*info->is_nulls)[i] = true; \
1442 } \
1443\
1444 out += sizeof(typ); \
1445 } while (0)
1446
1447#define HANDLE_ARRAY(typ, conv, access) \
1448 do { \
1449 if (NULL != dst_size) \
1450 *dst_size = sizeof(typ) *(header.dim); \
1451 out = GNUNET_new_array (header.dim, typ); \
1452 *((void **) dst) = out; \
1453 for (uint32_t i = 0; i < header.dim; i++) \
1454 { \
1455 HANDLE_ELEMENT (typ, conv, access); \
1456 } \
1457 } while (0)
1458
1459#define DEREF(typ, conv) \
1460 *(typ *) out = conv (*(typ *) in)
1461
1462#define ACCESS_ABS(typ, conv) \
1463 ((typ *) out)->abs_value_us = conv (*(uint64_t *) in)
1464
1465#define ACCESS_REL(typ, conv) \
1466 ((typ *) out)->rel_value_us = conv (*(uint64_t *) in)
1467
1468#define ACCESS_TSTMP(typ, conv) \
1469 ((typ *) out)->abs_time.abs_value_us = conv (*(uint64_t *) in)
1470
1471 switch (info->typ)
1472 {
1473 case array_of_bool:
1474 HANDLE_ARRAY (bool, /* no conv */, DEREF);
1475 break;
1476 case array_of_int16:
1477 HANDLE_ARRAY (int16_t, ntohs, DEREF);
1478 break;
1479 case array_of_uint16:
1480 HANDLE_ARRAY (uint16_t, ntohs, DEREF);
1481 break;
1482 case array_of_uint32:
1483 HANDLE_ARRAY (uint32_t, ntohl, DEREF);
1484 break;
1485 case array_of_uint64:
1486 HANDLE_ARRAY (uint64_t, GNUNET_ntohll, DEREF);
1487 break;
1488 case array_of_abs_time:
1491 ACCESS_ABS);
1492 break;
1493 case array_of_rel_time:
1496 ACCESS_REL);
1497 break;
1498 case array_of_timestamp:
1501 ACCESS_TSTMP);
1502 break;
1503 case array_of_byte:
1504 if (0 == info->same_size)
1505 *info->sizes = GNUNET_new_array (header.dim, size_t);
1506 /* fallthrough */
1507 case array_of_string:
1508 {
1509 size_t total_sz = 0;
1510 bool is_string = (array_of_string == info->typ);
1517 uint32_t elem_sz[header.dim];
1524 uint32_t in_adv[header.dim];
1525 bool is_null[header.dim];
1526
1527 memset (elem_sz, 0, sizeof(elem_sz));
1528 memset (in_adv, 0, sizeof(in_adv));
1529 memset (is_null, 0, sizeof(is_null));
1530
1531 /* first, calculate total size required for allocation */
1532 for (uint32_t i = 0; i < header.dim; i++)
1533 {
1534 int32_t sz = ntohl (*(int32_t *) in);
1535
1536 if (-1 == sz) /* signifies NULL entry */
1537 {
1538 FAIL_IF (! info->allow_nulls);
1539 is_null[i] = true;
1540 elem_sz[i] = info->same_size ? info->same_size : 0;
1541 in_adv[i] = 0;
1542 }
1543 else
1544 {
1545 FAIL_IF (0 > sz);
1546 elem_sz[i] = sz;
1547 in_adv[i] = sz;
1548 }
1549 FAIL_IF (info->same_size &&
1550 (elem_sz[i] != info->same_size));
1551
1552 if (info->allow_nulls)
1553 (*info->is_nulls)[i] = is_null[i];
1554
1555 if ((! is_string) &&
1556 (! info->same_size))
1557 (*info->sizes)[i] = elem_sz[i];
1558
1559 total_sz += elem_sz[i];
1560 /* add room for terminator for non-NULL entry of type string */
1561 total_sz += (is_string && ! is_null[i]) ? 1 : 0;
1562 in += sizeof(int32_t);
1563 in += in_adv[i];
1564
1565 FAIL_IF (total_sz < elem_sz[i]);
1566 }
1567
1568 FAIL_IF ((! info->allow_nulls) && (0 == total_sz));
1569 if (NULL != dst_size)
1570 *dst_size = total_sz;
1571
1572 out = GNUNET_malloc (total_sz);
1573 *((void **) dst) = out;
1574 in = data + sizeof(header); /* reset to beginning of input */
1575
1576 /* Finally, copy the data */
1577 for (uint32_t i = 0; i < header.dim; i++)
1578 {
1579 in += sizeof(uint32_t); /* skip length */
1580 if (! is_null[i])
1581 GNUNET_memcpy (out, in, elem_sz[i]);
1582
1583 in += in_adv[i];
1584 out += elem_sz[i];
1585 out += (is_string && ! is_null[i]) ? 1 : 0;
1586 }
1587 break;
1588 }
1589 default:
1590 FAIL_IF (1 != 0);
1591 }
1592 }
1593
1594 return GNUNET_OK;
1595
1596FAIL:
1597 GNUNET_free (*(void **) dst);
1598 return GNUNET_SYSERR;
1599#undef FAIL_IF
1600#undef DEREF
1601#undef ACCESS_ABS
1602#undef ACCESS_REL
1603#undef ACCESS_TSTMP
1604#undef HANDLE_ARRAY
1605#undef HANDLE_ELEMENT
1606}
#define INT_MAX
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static char * data
The data to insert into the dht.
uint32_t ndim
@ array_of_int16
Definition pq.h:137
@ array_of_byte
Definition pq.h:141
@ array_of_uint32
Definition pq.h:139
@ array_of_string
Definition pq.h:142
@ array_of_rel_time
Definition pq.h:144
@ array_of_uint16
Definition pq.h:138
@ array_of_uint64
Definition pq.h:140
@ array_of_abs_time
Definition pq.h:143
@ array_of_timestamp
Definition pq.h:145
@ array_of_bool
Definition pq.h:136
#define DEREF(typ, conv)
#define FAIL_IF(cond)
#define ACCESS_ABS(typ, conv)
#define ACCESS_REL(typ, conv)
#define HANDLE_ARRAY(typ, conv, access)
#define ACCESS_TSTMP(typ, conv)
Closure for the array result specifications.
The header for a postgresql array in binary format.
Definition pq.h:155

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

Referenced by GNUNET_PQ_result_spec_array_abs_time(), GNUNET_PQ_result_spec_array_allow_nulls(), GNUNET_PQ_result_spec_array_bool(), GNUNET_PQ_result_spec_array_fixed_size(), GNUNET_PQ_result_spec_array_int16(), 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:

◆ GNUNET_PQ_result_spec_array_allow_nulls()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_allow_nulls ( struct GNUNET_PQ_ResultSpec  rs,
bool **  is_nulls 
)

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

Parameters
rsresult spec entry to modify, MUST be one for the array types
[out]is_nullslocation where to put the array of bools, whose elements will be set to 'true' if the value was indeed NULL, or to 'false' if the value was non-NULL. This parameter MUST NOT be NULL itself. The length of the allocated array will be equal to the length of the result for the values in rs.
Returns
array entry for the result specification to use

Definition at line 1610 of file pq_result_helper.c.

1613{
1614 struct GNUNET_PQ_ResultSpec rsr;
1615 struct array_result_cls *info = rs.cls;
1616
1618 GNUNET_assert (NULL != is_nulls);
1619 info->allow_nulls = true;
1620 info->is_nulls = is_nulls;
1621
1622 rsr = rs;
1623 return rsr;
1624}
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.
void * cls
Closure for conv and cleaner.

References extract_array_generic(), GNUNET_assert, info, and array_result_cls::is_nulls.

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

1633{
1634
1635 struct array_result_cls *info = cls;
1636 void **dst = rd;
1637
1638 if ((array_of_byte == info->typ) &&
1639 (0 == info->same_size) &&
1640 (NULL != info->sizes))
1641 GNUNET_free (*(info->sizes));
1642
1643 if (info->allow_nulls)
1644 GNUNET_free (*info->is_nulls);
1645
1646 GNUNET_free (cls);
1647 GNUNET_free (*dst);
1648 *dst = NULL;
1649}

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_int16(), 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 1653 of file pq_result_helper.c.

1658{
1659 struct array_result_cls *info =
1661
1662 info->num = num;
1663 info->typ = array_of_bool;
1666 "bool",
1667 &info->oid));
1668
1669 {
1670 struct GNUNET_PQ_ResultSpec res = {
1672 .cleaner = array_cleanup,
1673 .dst = (void *) dst,
1674 .fname = name,
1675 .cls = info
1676 };
1677 return res;
1678 }
1679}
static struct GNUNET_FS_DirectoryBuilder * db
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:788
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void array_cleanup(void *cls, void *rd)
Cleanup of the data and closure of an array spec.

References array_cleanup(), array_of_bool, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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_int16()

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

array of int16_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 i16s.
[out]dstpointer to where to store the an array of num int16_t's. 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_int16;
1696 "int2",
1697 &info->oid));
1698
1699 {
1700 struct GNUNET_PQ_ResultSpec res = {
1702 .cleaner = array_cleanup,
1703 .dst = (void *) dst,
1704 .fname = name,
1705 .cls = info
1706 };
1707 return res;
1708 }
1709}

References array_cleanup(), array_of_int16, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1713 of file pq_result_helper.c.

1718{
1719 struct array_result_cls *info =
1721
1722 info->num = num;
1723 info->typ = array_of_uint16;
1726 "int2",
1727 &info->oid));
1728
1729 {
1730 struct GNUNET_PQ_ResultSpec res = {
1732 .cleaner = array_cleanup,
1733 .dst = (void *) dst,
1734 .fname = name,
1735 .cls = info
1736 };
1737 return res;
1738 }
1739}

References array_cleanup(), array_of_uint16, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1743 of file pq_result_helper.c.

1748{
1749 struct array_result_cls *info =
1751
1752 info->num = num;
1753 info->typ = array_of_uint32;
1756 "int4",
1757 &info->oid));
1758
1759 {
1760 struct GNUNET_PQ_ResultSpec res = {
1762 .cleaner = array_cleanup,
1763 .dst = (void *) dst,
1764 .fname = name,
1765 .cls = info
1766 };
1767 return res;
1768 }
1769}

References array_cleanup(), array_of_uint32, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1773 of file pq_result_helper.c.

1778{
1779 struct array_result_cls *info =
1781
1782 info->num = num;
1783 info->typ = array_of_uint64;
1786 "int8",
1787 &info->oid));
1788
1789 {struct GNUNET_PQ_ResultSpec res = {
1791 .cleaner = array_cleanup,
1792 .dst = (void *) dst,
1793 .fname = name,
1794 .cls = info
1795 };
1796 return res;}
1797}

References array_cleanup(), array_of_uint64, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1801 of file pq_result_helper.c.

1806{
1807 struct array_result_cls *info =
1809
1810 info->num = num;
1811 info->typ = array_of_abs_time;
1814 "int8",
1815 &info->oid));
1816
1817 {struct GNUNET_PQ_ResultSpec res = {
1819 .cleaner = array_cleanup,
1820 .dst = (void *) dst,
1821 .fname = name,
1822 .cls = info
1823 };
1824 return res;}
1825}

References array_cleanup(), array_of_abs_time, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1829 of file pq_result_helper.c.

1834{
1835 struct array_result_cls *info =
1837
1838 info->num = num;
1839 info->typ = array_of_rel_time;
1842 "int8",
1843 &info->oid));
1844
1845 {
1846 struct GNUNET_PQ_ResultSpec res = {
1848 .cleaner = array_cleanup,
1849 .dst = (void *) dst,
1850 .fname = name,
1851 .cls = info
1852 };
1853 return res;
1854 }
1855}

References array_cleanup(), array_of_rel_time, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1859 of file pq_result_helper.c.

1864{
1865 struct array_result_cls *info =
1867
1868 info->num = num;
1869 info->typ = array_of_timestamp;
1872 "int8",
1873 &info->oid));
1874
1875 {
1876 struct GNUNET_PQ_ResultSpec res = {
1878 .cleaner = array_cleanup,
1879 .dst = (void *) dst,
1880 .fname = name,
1881 .cls = info
1882 };
1883 return res;
1884 }
1885}

References array_cleanup(), array_of_timestamp, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 of sizes given in size, allocated
Returns
array entry for the result specification to use

Definition at line 1889 of file pq_result_helper.c.

1895{
1896 struct array_result_cls *info =
1898
1899 info->num = num;
1900 info->sizes = sizes;
1901 info->typ = array_of_byte;
1904 "bytea",
1905 &info->oid));
1906
1907 {
1908 struct GNUNET_PQ_ResultSpec res = {
1910 .cleaner = array_cleanup,
1911 .dst = (void *) dst,
1912 .fname = name,
1913 .cls = info
1914 };
1915 return res;
1916 }
1917}

References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 @num fixed-size elements
Returns
array entry for the result specification to use

Definition at line 1921 of file pq_result_helper.c.

1927{
1928 struct array_result_cls *info =
1930
1931 info->num = num;
1932 info->same_size = size;
1933 info->typ = array_of_byte;
1936 "bytea",
1937 &info->oid));
1938
1939 {
1940 struct GNUNET_PQ_ResultSpec res = {
1942 .cleaner = array_cleanup,
1943 .dst = (void *) dst,
1944 .fname = name,
1945 .cls = info
1946 };
1947 return res;
1948 }
1949}
static unsigned int size
Size of the "table".
Definition peer.c:68

References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 continuous array of num 0-terminated strings
Returns
array entry for the result specification to use

Definition at line 1953 of file pq_result_helper.c.

1958{
1959 struct array_result_cls *info =
1961
1962 info->num = num;
1963 info->typ = array_of_string;
1966 "text",
1967 &info->oid));
1968
1969 {
1970 struct GNUNET_PQ_ResultSpec res = {
1972 .cleaner = array_cleanup,
1973 .dst = (void *) dst,
1974 .fname = name,
1975 .cls = info
1976 };
1977 return res;
1978 }
1979}

References array_cleanup(), array_of_string, GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, 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 1996 of file pq_result_helper.c.

2002{
2003 struct GNUNET_CRYPTO_BlindSignPublicKey **bpk = dst;
2005 size_t len;
2006 const char *res;
2007 int fnum;
2008 uint32_t be;
2009
2010 (void) cls;
2011 (void) dst_size;
2012 fnum = PQfnumber (result,
2013 fname);
2014 if (fnum < 0)
2015 {
2016 GNUNET_break (0);
2017 return GNUNET_SYSERR;
2018 }
2019 if (PQgetisnull (result,
2020 row,
2021 fnum))
2022 return GNUNET_NO;
2023
2024 /* if a field is null, continue but
2025 * remember that we now return a different result */
2026 len = PQgetlength (result,
2027 row,
2028 fnum);
2029 res = PQgetvalue (result,
2030 row,
2031 fnum);
2032 if (len < sizeof (be))
2033 {
2034 GNUNET_break (0);
2035 return GNUNET_SYSERR;
2036 }
2037 GNUNET_memcpy (&be,
2038 res,
2039 sizeof (be));
2040 res += sizeof (be);
2041 len -= sizeof (be);
2043 tmp->cipher = ntohl (be);
2044 tmp->rc = 1;
2045 switch (tmp->cipher)
2046 {
2048 break;
2052 len);
2053 if (NULL == tmp->details.rsa_public_key)
2054 {
2055 GNUNET_break (0);
2056 GNUNET_free (tmp);
2057 return GNUNET_SYSERR;
2058 }
2060 len,
2061 &tmp->pub_key_hash);
2062 *bpk = tmp;
2063 return GNUNET_OK;
2065 if (sizeof (tmp->details.cs_public_key) != len)
2066 {
2067 GNUNET_break (0);
2068 GNUNET_free (tmp);
2069 return GNUNET_SYSERR;
2070 }
2072 res,
2073 len);
2075 len,
2076 &tmp->pub_key_hash);
2077 *bpk = tmp;
2078 return GNUNET_OK;
2079 }
2080 GNUNET_break (0);
2081 GNUNET_free (tmp);
2082 return GNUNET_SYSERR;
2083}
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:40
@ 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::@20 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 2094 of file pq_result_helper.c.

2096{
2098
2099 (void) cls;
2100 if (NULL != *pub)
2101 {
2103 *pub = NULL;
2104 }
2105}
static struct GNUNET_CRYPTO_EddsaPublicKey pub
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 2109 of file pq_result_helper.c.

2112{
2113 struct GNUNET_PQ_ResultSpec res = {
2115 .cleaner = &clean_blind_sign_pub,
2116 .dst = (void *) pub,
2117 .fname = name
2118 };
2119
2120 return res;
2121}
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(), GNUNET_PQ_ResultSpec::conv, 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 2138 of file pq_result_helper.c.

2144{
2145 struct GNUNET_CRYPTO_BlindSignPrivateKey **bpk = dst;
2147 size_t len;
2148 const char *res;
2149 int fnum;
2150 uint32_t be;
2151
2152 (void) cls;
2153 (void) dst_size;
2154 fnum = PQfnumber (result,
2155 fname);
2156 if (fnum < 0)
2157 {
2158 GNUNET_break (0);
2159 return GNUNET_SYSERR;
2160 }
2161 if (PQgetisnull (result,
2162 row,
2163 fnum))
2164 return GNUNET_NO;
2165
2166 /* if a field is null, continue but
2167 * remember that we now return a different result */
2168 len = PQgetlength (result,
2169 row,
2170 fnum);
2171 res = PQgetvalue (result,
2172 row,
2173 fnum);
2174 if (len < sizeof (be))
2175 {
2176 GNUNET_break (0);
2177 return GNUNET_SYSERR;
2178 }
2179 GNUNET_memcpy (&be,
2180 res,
2181 sizeof (be));
2182 res += sizeof (be);
2183 len -= sizeof (be);
2185 tmp->cipher = ntohl (be);
2186 tmp->rc = 1;
2187 switch (tmp->cipher)
2188 {
2190 break;
2194 len);
2195 if (NULL == tmp->details.rsa_private_key)
2196 {
2197 GNUNET_break (0);
2198 GNUNET_free (tmp);
2199 return GNUNET_SYSERR;
2200 }
2201 *bpk = tmp;
2202 return GNUNET_OK;
2204 if (sizeof (tmp->details.cs_private_key) != len)
2205 {
2206 GNUNET_break (0);
2207 GNUNET_free (tmp);
2208 return GNUNET_SYSERR;
2209 }
2211 res,
2212 len);
2213 *bpk = tmp;
2214 return GNUNET_OK;
2215 }
2216 GNUNET_break (0);
2217 GNUNET_free (tmp);
2218 return GNUNET_SYSERR;
2219}
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::@21 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 2230 of file pq_result_helper.c.

2232{
2233 struct GNUNET_CRYPTO_BlindSignPrivateKey **priv = rd;
2234
2235 (void) cls;
2236 if (NULL != *priv)
2237 {
2239 *priv = NULL;
2240 }
2241}
void GNUNET_CRYPTO_blind_sign_priv_decref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Decrement reference counter of a bsign_priv, and free it if it reaches zero.

References GNUNET_CRYPTO_blind_sign_priv_decref(), 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 2245 of file pq_result_helper.c.

2248{
2249 struct GNUNET_PQ_ResultSpec res = {
2251 .cleaner = &clean_blind_sign_priv,
2252 .dst = (void *) priv,
2253 .fname = name
2254 };
2255
2256 return res;
2257}
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(), GNUNET_PQ_ResultSpec::conv, extract_blind_sign_priv(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_blinded_sig()

static enum GNUNET_GenericReturnValue extract_blinded_sig ( 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 2274 of file pq_result_helper.c.

2280{
2281 struct GNUNET_CRYPTO_BlindedSignature **sig = dst;
2283 size_t len;
2284 const char *res;
2285 int fnum;
2286 uint32_t be[2];
2287
2288 (void) cls;
2289 (void) dst_size;
2290 fnum = PQfnumber (result,
2291 fname);
2292 if (fnum < 0)
2293 {
2294 GNUNET_break (0);
2295 return GNUNET_SYSERR;
2296 }
2297 if (PQgetisnull (result,
2298 row,
2299 fnum))
2300 return GNUNET_NO;
2301
2302 /* if a field is null, continue but
2303 * remember that we now return a different result */
2304 len = PQgetlength (result,
2305 row,
2306 fnum);
2307 res = PQgetvalue (result,
2308 row,
2309 fnum);
2310 if (len < sizeof (be))
2311 {
2312 GNUNET_break (0);
2313 return GNUNET_SYSERR;
2314 }
2315 GNUNET_memcpy (&be,
2316 res,
2317 sizeof (be));
2318 if (0x01 != ntohl (be[1])) /* magic marker: blinded */
2319 {
2320 GNUNET_break (0);
2321 return GNUNET_SYSERR;
2322 }
2323 res += sizeof (be);
2324 len -= sizeof (be);
2326 bs->rc = 1;
2327 bs->cipher = ntohl (be[0]);
2328 switch (bs->cipher)
2329 {
2331 break;
2335 len);
2336 if (NULL == bs->details.blinded_rsa_signature)
2337 {
2338 GNUNET_break (0);
2339 GNUNET_free (bs);
2340 return GNUNET_SYSERR;
2341 }
2342 *sig = bs;
2343 return GNUNET_OK;
2345 if (sizeof (bs->details.blinded_cs_answer) != len)
2346 {
2347 GNUNET_break (0);
2348 GNUNET_free (bs);
2349 return GNUNET_SYSERR;
2350 }
2352 res,
2353 len);
2354 *sig = bs;
2355 return GNUNET_OK;
2356 }
2357 GNUNET_break (0);
2358 GNUNET_free (bs);
2359 return GNUNET_SYSERR;
2360}
Type for blinded signatures.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
union GNUNET_CRYPTO_BlindedSignature::@19 details
Details, depending on cipher.

References GNUNET_CRYPTO_BlindedSignature::blinded_cs_answer, GNUNET_CRYPTO_BlindedSignature::blinded_rsa_signature, GNUNET_CRYPTO_BlindedSignature::cipher, GNUNET_CRYPTO_BlindedSignature::details, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_CRYPTO_BlindedSignature::rc, res, and result.

Referenced by GNUNET_PQ_result_spec_blinded_sig().

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

◆ clean_blinded_sig()

static void clean_blinded_sig ( 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 2371 of file pq_result_helper.c.

2373{
2374 struct GNUNET_CRYPTO_BlindedSignature **b_sig = rd;
2375
2376 (void) cls;
2378}
void GNUNET_CRYPTO_blinded_sig_decref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Decrement reference counter of a blind_sig, and free it if it reaches zero.

References GNUNET_CRYPTO_blinded_sig_decref(), and rd.

Referenced by GNUNET_PQ_result_spec_blinded_sig().

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

◆ GNUNET_PQ_result_spec_blinded_sig()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blinded_sig ( const char *  name,
struct GNUNET_CRYPTO_BlindedSignature **  b_sig 
)

Blinded signature expected.

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

Definition at line 2382 of file pq_result_helper.c.

2385{
2386 struct GNUNET_PQ_ResultSpec res = {
2388 .cleaner = &clean_blinded_sig,
2389 .dst = (void *) b_sig,
2390 .fname = name
2391 };
2392
2393 return res;
2394}
static void clean_blinded_sig(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
static enum GNUNET_GenericReturnValue extract_blinded_sig(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_blinded_sig(), GNUNET_PQ_ResultSpec::conv, extract_blinded_sig(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function:

◆ extract_unblinded_sig()

static enum GNUNET_GenericReturnValue extract_unblinded_sig ( 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 2411 of file pq_result_helper.c.

2417{
2418 struct GNUNET_CRYPTO_UnblindedSignature **sig = dst;
2420 size_t len;
2421 const char *res;
2422 int fnum;
2423 uint32_t be[2];
2424
2425 (void) cls;
2426 (void) dst_size;
2427 fnum = PQfnumber (result,
2428 fname);
2429 if (fnum < 0)
2430 {
2431 GNUNET_break (0);
2432 return GNUNET_SYSERR;
2433 }
2434 if (PQgetisnull (result,
2435 row,
2436 fnum))
2437 return GNUNET_NO;
2438
2439 /* if a field is null, continue but
2440 * remember that we now return a different result */
2441 len = PQgetlength (result,
2442 row,
2443 fnum);
2444 res = PQgetvalue (result,
2445 row,
2446 fnum);
2447 if (len < sizeof (be))
2448 {
2449 GNUNET_break (0);
2450 return GNUNET_SYSERR;
2451 }
2452 GNUNET_memcpy (&be,
2453 res,
2454 sizeof (be));
2455 if (0x00 != ntohl (be[1])) /* magic marker: unblinded */
2456 {
2457 GNUNET_break (0);
2458 return GNUNET_SYSERR;
2459 }
2460 res += sizeof (be);
2461 len -= sizeof (be);
2463 ubs->rc = 1;
2464 ubs->cipher = ntohl (be[0]);
2465 switch (ubs->cipher)
2466 {
2468 break;
2472 len);
2473 if (NULL == ubs->details.rsa_signature)
2474 {
2475 GNUNET_break (0);
2476 GNUNET_free (ubs);
2477 return GNUNET_SYSERR;
2478 }
2479 *sig = ubs;
2480 return GNUNET_OK;
2482 if (sizeof (ubs->details.cs_signature) != len)
2483 {
2484 GNUNET_break (0);
2485 GNUNET_free (ubs);
2486 return GNUNET_SYSERR;
2487 }
2489 res,
2490 len);
2491 *sig = ubs;
2492 return GNUNET_OK;
2493 }
2494 GNUNET_break (0);
2495 GNUNET_free (ubs);
2496 return GNUNET_SYSERR;
2497}
Type of (unblinded) signatures.
union GNUNET_CRYPTO_UnblindedSignature::@18 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.

References GNUNET_CRYPTO_UnblindedSignature::cipher, GNUNET_CRYPTO_UnblindedSignature::cs_signature, GNUNET_CRYPTO_UnblindedSignature::details, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_CRYPTO_UnblindedSignature::rc, res, result, and GNUNET_CRYPTO_UnblindedSignature::rsa_signature.

Referenced by GNUNET_PQ_result_spec_unblinded_sig().

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

◆ clean_unblinded_sig()

static void clean_unblinded_sig ( 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 2508 of file pq_result_helper.c.

2510{
2511 struct GNUNET_CRYPTO_UnblindedSignature **ub_sig = rd;
2512
2513 (void) cls;
2515}
void GNUNET_CRYPTO_unblinded_sig_decref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Decrement reference counter of a ub_sig, and free it if it reaches zero.

References GNUNET_CRYPTO_unblinded_sig_decref(), and rd.

Referenced by GNUNET_PQ_result_spec_unblinded_sig().

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

◆ GNUNET_PQ_result_spec_unblinded_sig()

struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_unblinded_sig ( const char *  name,
struct GNUNET_CRYPTO_UnblindedSignature **  ub_sig 
)

Unblinded signature expected.

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

Definition at line 2519 of file pq_result_helper.c.

2522{
2523 struct GNUNET_PQ_ResultSpec res = {
2525 .cleaner = &clean_unblinded_sig,
2526 .dst = (void *) ub_sig,
2527 .fname = name
2528 };
2529
2530 return res;
2531}
static enum GNUNET_GenericReturnValue extract_unblinded_sig(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_unblinded_sig(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.

References clean_unblinded_sig(), GNUNET_PQ_ResultSpec::conv, extract_unblinded_sig(), GNUNET_PQ_ResultSpec::fname, name, and res.

Here is the call graph for this function: