GNUnet 0.21.1
pq_query_helper.c File Reference

functions to initialize parameter arrays More...

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

Go to the source code of this file.

Data Structures

struct  qconv_array_cls
 Closure for the array type handlers. More...
 

Macros

#define RETURN_UNLESS(cond)
 

Functions

static int qconv_null (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_null (void)
 Generate query parameter to create a NULL value. More...
 
static int qconv_fixed (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size)
 Generate query parameter for a buffer ptr of ptr_size bytes. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_string (const char *ptr)
 Generate query parameter for a string. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_bool (bool b)
 Pass a boolean into a query. More...
 
static int qconv_uint16 (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint16 (const uint16_t *x)
 Generate query parameter for an uint16_t in host byte order. More...
 
static int qconv_uint32 (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint32 (const uint32_t *x)
 Generate query parameter for an uint32_t in host byte order. More...
 
static int qconv_uint64 (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint64 (const uint64_t *x)
 Generate query parameter for an uint64_t in host byte order. More...
 
static int qconv_int64 (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_int64 (const int64_t *x)
 Generate query parameter for an int64_t in host byte order. More...
 
static int qconv_rsa_public_key (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x)
 Generate query parameter for an RSA public key. More...
 
static int qconv_rsa_signature (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
 Generate query parameter for an RSA signature. More...
 
static int qconv_rel_time (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x)
 Generate query parameter for a relative time value. More...
 
static int qconv_abs_time (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
 Generate query parameter for an absolute time value. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x)
 Generate query parameter for an absolute time value. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x)
 Generate query parameter for a timestamp. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp_nbo (const struct GNUNET_TIME_TimestampNBO *x)
 Generate query parameter for a timestamp in NBO. More...
 
static void qconv_array_cls_cleanup (void *cls)
 Callback to cleanup a qconv_array_cls to be used during GNUNET_PQ_cleanup_query_params_closures. More...
 
static int qconv_array (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters for arrays. More...
 
static struct GNUNET_PQ_QueryParam query_param_array_generic (unsigned int num, bool continuous, const void *elements, const size_t *sizes, size_t same_size, enum array_types typ, Oid oid)
 Function to genreate a typ specific query parameter and corresponding closure. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bool (unsigned int num, const bool *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of bool in host byte order. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint16 (unsigned int num, const uint16_t *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of uint16_t in host byte order. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint32 (unsigned int num, const uint32_t *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of uint32_t in host byte order. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint64 (unsigned int num, const uint64_t *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of uint64 in host byte order. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes (unsigned int num, const void *elements, const size_t *sizes, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of buffers elements, each of corresponding size given in sizes. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes (unsigned int num, const void *elements[static num], const size_t *sizes, struct GNUNET_PQ_Context *db)
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes_same_size (unsigned int num, const void *elements, size_t same_size, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of buffers elements, each of the same size size. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes_same_size (unsigned int num, const void *elements[static num], size_t same_size, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of pointers to buffers elements, each of the same size size. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_string (unsigned int num, const char *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of strings (continuous) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_string (unsigned int num, const char *elements[static num], struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of strings (pointers) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_abs_time (unsigned int num, const struct GNUNET_TIME_Absolute *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of absolute time stamps (continuous) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_abs_time (unsigned int num, const struct GNUNET_TIME_Absolute *elements[], struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of absolute time stamps (pointers) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_rel_time (unsigned int num, const struct GNUNET_TIME_Relative *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of relative time stamps (continuous) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_rel_time (unsigned int num, const struct GNUNET_TIME_Relative *elements[], struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of relative time stamps (pointers) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_timestamp (unsigned int num, const struct GNUNET_TIME_Timestamp *elements, struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of time stamps (continuous) More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_timestamp (unsigned int num, const struct GNUNET_TIME_Timestamp *elements[], struct GNUNET_PQ_Context *db)
 Generate query parameter for an array of time stamps (pointers) More...
 
static int qconv_blind_sign_pub (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_pub (const struct GNUNET_CRYPTO_BlindSignPublicKey *pub)
 Generate query parameter for a blind sign public key of variable size. More...
 
static int qconv_blind_sign_priv (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
 Function called to convert input argument into SQL parameters. More...
 
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_priv (const struct GNUNET_CRYPTO_BlindSignPrivateKey *priv)
 Generate query parameter for a blind sign private key of variable size. More...
 

Detailed Description

functions to initialize parameter arrays

Author
Christian Grothoff

Definition in file pq_query_helper.c.

Macro Definition Documentation

◆ RETURN_UNLESS

#define RETURN_UNLESS (   cond)
Value:
do { \
if (! (cond)) \
{ \
GNUNET_break ((cond)); \
noerror = false; \
goto DONE; \
} \
} while (0)

Function Documentation

◆ qconv_null()

static int qconv_null ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 47 of file pq_query_helper.c.

56{
57 (void) scratch;
58 (void) scratch_length;
59 (void) data;
60 (void) data_len;
61 GNUNET_break (NULL == cls);
62 if (1 != param_length)
63 return -1;
64 param_values[0] = NULL;
65 param_lengths[0] = 0;
66 param_formats[0] = 1;
67 return 0;
68}
static char * data
The data to insert into the dht.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References data, and GNUNET_break.

Referenced by GNUNET_PQ_query_param_null().

Here is the caller graph for this function:

◆ GNUNET_PQ_query_param_null()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_null ( void  )

Generate query parameter to create a NULL value.

Returns
query parameter to use to insert NULL into DB

Definition at line 72 of file pq_query_helper.c.

73{
74 struct GNUNET_PQ_QueryParam res = {
75 .conv = &qconv_null,
76 .num_params = 1
77 };
78
79 return res;
80}
static char * res
Currently read line or NULL on EOF.
static int qconv_null(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
Description of a DB query parameter.
Definition: gnunet_pq_lib.h:83

References qconv_null(), and res.

Referenced by postgres_plugin_put().

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

◆ qconv_fixed()

static int qconv_fixed ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 98 of file pq_query_helper.c.

107{
108 (void) scratch;
109 (void) scratch_length;
110 GNUNET_break (NULL == cls);
111 if (1 != param_length)
112 return -1;
113 param_values[0] = (void *) data;
114 param_lengths[0] = data_len;
115 param_formats[0] = 1;
116 return 0;
117}

References data, and GNUNET_break.

Referenced by GNUNET_PQ_query_param_fixed_size().

Here is the caller graph for this function:

◆ GNUNET_PQ_query_param_fixed_size()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size ( const void *  ptr,
size_t  ptr_size 
)

Generate query parameter for a buffer ptr of ptr_size bytes.

Parameters
ptrpointer to the query parameter to pass
ptr_sizenumber of bytes in ptr
Returns
query parameter to use

Definition at line 121 of file pq_query_helper.c.

123{
124 struct GNUNET_PQ_QueryParam res = {
125 .conv = &qconv_fixed,
126 .conv_cls = NULL,
127 .data = ptr,
128 .size = ptr_size,
129 .num_params = 1
130 };
131
132 return res;
133}
static int qconv_fixed(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_fixed(), res, and GNUNET_PQ_QueryParam::size.

Referenced by GNUNET_PQ_query_param_bool(), GNUNET_PQ_query_param_string(), namecache_postgres_cache_block(), namestore_postgres_store_records(), postgres_plugin_put(), and postgres_plugin_remove_key().

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

◆ GNUNET_PQ_query_param_string()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_string ( const char *  ptr)

Generate query parameter for a string.

Parameters
ptrpointer to the string query parameter to pass
Returns
query parameter to use

Definition at line 137 of file pq_query_helper.c.

138{
140 strlen (ptr));
141}
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size(const void *ptr, size_t ptr_size)
Generate query parameter for a buffer ptr of ptr_size bytes.

References GNUNET_PQ_query_param_fixed_size().

Referenced by GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_run_sql(), namestore_postgres_clear_editor_hint(), namestore_postgres_edit_records(), namestore_postgres_lookup_records(), and namestore_postgres_store_records().

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

◆ GNUNET_PQ_query_param_bool()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_bool ( bool  b)

Pass a boolean into a query.

Parameters
bboolean bit to pass
Returns
query parameter to use

Definition at line 145 of file pq_query_helper.c.

146{
147 static uint8_t bt = 1;
148 static uint8_t bf = 0;
149
150 return GNUNET_PQ_query_param_fixed_size (b ? &bt : &bf,
151 sizeof (uint8_t));
152}

References GNUNET_PQ_query_param_fixed_size().

Here is the call graph for this function:

◆ qconv_uint16()

static int qconv_uint16 ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 170 of file pq_query_helper.c.

179{
180 const uint16_t *u_hbo = data;
181 uint16_t *u_nbo;
182
183 (void) scratch;
184 (void) scratch_length;
185 GNUNET_break (NULL == cls);
186 if (1 != param_length)
187 return -1;
188 u_nbo = GNUNET_new (uint16_t);
189 scratch[0] = u_nbo;
190 *u_nbo = htons (*u_hbo);
191 param_values[0] = (void *) u_nbo;
192 param_lengths[0] = sizeof(uint16_t);
193 param_formats[0] = 1;
194 return 1;
195}
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References data, GNUNET_break, and GNUNET_new.

Referenced by GNUNET_PQ_query_param_uint16().

Here is the caller graph for this function:

◆ GNUNET_PQ_query_param_uint16()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint16 ( const uint16_t *  x)

Generate query parameter for an uint16_t in host byte order.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 199 of file pq_query_helper.c.

200{
201 struct GNUNET_PQ_QueryParam res = {
202 .conv = &qconv_uint16,
203 .data = x,
204 .size = sizeof(*x),
205 .num_params = 1
206 };
207
208 return res;
209}
static int qconv_uint16(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_uint16(), and res.

Referenced by postgres_plugin_get_key().

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

◆ qconv_uint32()

static int qconv_uint32 ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 227 of file pq_query_helper.c.

236{
237 const uint32_t *u_hbo = data;
238 uint32_t *u_nbo;
239
240 (void) scratch;
241 (void) scratch_length;
242 GNUNET_break (NULL == cls);
243 if (1 != param_length)
244 return -1;
245 u_nbo = GNUNET_new (uint32_t);
246 scratch[0] = u_nbo;
247 *u_nbo = htonl (*u_hbo);
248 param_values[0] = (void *) u_nbo;
249 param_lengths[0] = sizeof(uint32_t);
250 param_formats[0] = 1;
251 return 1;
252}

References data, GNUNET_break, and GNUNET_new.

Referenced by GNUNET_PQ_query_param_uint32().

Here is the caller graph for this function:

◆ GNUNET_PQ_query_param_uint32()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint32 ( const uint32_t *  x)

Generate query parameter for an uint32_t in host byte order.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 256 of file pq_query_helper.c.

257{
258 struct GNUNET_PQ_QueryParam res = {
259 .conv = &qconv_uint32,
260 .data = x,
261 .size = sizeof(*x),
262 .num_params = 1
263 };
264
265 return res;
266}
static int qconv_uint32(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_uint32(), and res.

Referenced by namestore_postgres_store_records(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_key(), postgres_plugin_get_zero_anonymity(), and postgres_plugin_put().

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

◆ qconv_uint64()

static int qconv_uint64 ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 284 of file pq_query_helper.c.

293{
294 const uint64_t *u_hbo = data;
295 uint64_t *u_nbo;
296
297 (void) scratch;
298 (void) scratch_length;
299 GNUNET_break (NULL == cls);
300 if (1 != param_length)
301 return -1;
302 u_nbo = GNUNET_new (uint64_t);
303 scratch[0] = u_nbo;
304 *u_nbo = GNUNET_htonll (*u_hbo);
305 param_values[0] = (void *) u_nbo;
306 param_lengths[0] = sizeof(uint64_t);
307 param_formats[0] = 1;
308 return 1;
309}
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37

References data, GNUNET_break, GNUNET_htonll(), and GNUNET_new.

Referenced by GNUNET_PQ_query_param_uint64().

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

◆ GNUNET_PQ_query_param_uint64()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint64 ( const uint64_t *  x)

Generate query parameter for an uint64_t in host byte order.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 313 of file pq_query_helper.c.

314{
315 struct GNUNET_PQ_QueryParam res = {
316 .conv = &qconv_uint64,
317 .data = x,
318 .size = sizeof(*x),
319 .num_params = 1
320 };
321
322 return res;
323}
static int qconv_uint64(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_uint64(), and res.

Referenced by namestore_postgres_iterate_records(), namestore_postgres_store_records(), postgres_plugin_del(), postgres_plugin_get_key(), postgres_plugin_get_zero_anonymity(), postgres_plugin_put(), process_result(), and repl_proc().

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

◆ qconv_int64()

static int qconv_int64 ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 341 of file pq_query_helper.c.

350{
351 const int64_t *u_hbo = data;
352 int64_t *u_nbo;
353
354 (void) scratch;
355 (void) scratch_length;
356 GNUNET_break (NULL == cls);
357 if (1 != param_length)
358 return -1;
359 u_nbo = GNUNET_new (int64_t);
360 scratch[0] = u_nbo;
361 *u_nbo = GNUNET_htonll (*u_hbo);
362 param_values[0] = (void *) u_nbo;
363 param_lengths[0] = sizeof(int64_t);
364 param_formats[0] = 1;
365 return 1;
366}

References data, GNUNET_break, GNUNET_htonll(), and GNUNET_new.

Referenced by GNUNET_PQ_query_param_int64().

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

◆ GNUNET_PQ_query_param_int64()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_int64 ( const int64_t *  x)

Generate query parameter for an int64_t in host byte order.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 370 of file pq_query_helper.c.

371{
372 struct GNUNET_PQ_QueryParam res = {
373 .conv = &qconv_int64,
374 .data = x,
375 .size = sizeof(*x),
376 .num_params = 1
377 };
378
379 return res;
380}
static int qconv_int64(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_int64(), and res.

Here is the call graph for this function:

◆ qconv_rsa_public_key()

static int qconv_rsa_public_key ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 398 of file pq_query_helper.c.

407{
408 const struct GNUNET_CRYPTO_RsaPublicKey *rsa = data;
409 void *buf;
410 size_t buf_size;
411
412 GNUNET_break (NULL == cls);
413 if (1 != param_length)
414 return -1;
416 &buf);
417 scratch[0] = buf;
418 param_values[0] = (void *) buf;
419 param_lengths[0] = buf_size;
420 param_formats[0] = 1;
421 return 1;
422}
size_t GNUNET_CRYPTO_rsa_public_key_encode(const struct GNUNET_CRYPTO_RsaPublicKey *key, void **buffer)
Encode the public key in a format suitable for storing it into a file.
Definition: crypto_rsa.c:325
The public information of an RSA key pair.
Definition: crypto_rsa.c:53

References data, GNUNET_break, and GNUNET_CRYPTO_rsa_public_key_encode().

Referenced by GNUNET_PQ_query_param_rsa_public_key().

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

◆ GNUNET_PQ_query_param_rsa_public_key()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_public_key ( const struct GNUNET_CRYPTO_RsaPublicKey x)

Generate query parameter for an RSA public key.

The database must contain a BLOB type in the respective position.

Parameters
xthe query parameter to pass.
Returns
query parameter to use

Definition at line 426 of file pq_query_helper.c.

428{
429 struct GNUNET_PQ_QueryParam res = {
430 .conv = &qconv_rsa_public_key,
431 .data = x,
432 .num_params = 1
433 };
434
435 return res;
436}
static int qconv_rsa_public_key(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_rsa_public_key(), and res.

Here is the call graph for this function:

◆ qconv_rsa_signature()

static int qconv_rsa_signature ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 454 of file pq_query_helper.c.

463{
464 const struct GNUNET_CRYPTO_RsaSignature *sig = data;
465 void *buf;
466 size_t buf_size;
467
468 GNUNET_break (NULL == cls);
469 if (1 != param_length)
470 return -1;
472 &buf);
473 scratch[0] = buf;
474 param_values[0] = (void *) buf;
475 param_lengths[0] = buf_size;
476 param_formats[0] = 1;
477 return 1;
478}
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
Definition: crypto_rsa.c:1023
an RSA signature
Definition: crypto_rsa.c:65

References data, GNUNET_break, and GNUNET_CRYPTO_rsa_signature_encode().

Referenced by GNUNET_PQ_query_param_rsa_signature().

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

◆ GNUNET_PQ_query_param_rsa_signature()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_signature ( const struct GNUNET_CRYPTO_RsaSignature x)

Generate query parameter for an RSA signature.

The database must contain a BLOB type in the respective position.

Parameters
xthe query parameter to pass
Returns
query parameter to use

Definition at line 482 of file pq_query_helper.c.

483{
484 struct GNUNET_PQ_QueryParam res = {
485 .conv = &qconv_rsa_signature,
486 .data = x,
487 .num_params = 1
488 };
489
490 return res;
491}
static int qconv_rsa_signature(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_rsa_signature(), and res.

Here is the call graph for this function:

◆ qconv_rel_time()

static int qconv_rel_time ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 509 of file pq_query_helper.c.

518{
519 const struct GNUNET_TIME_Relative *u = data;
520 struct GNUNET_TIME_Relative rel;
521 uint64_t *u_nbo;
522
523 GNUNET_break (NULL == cls);
524 if (1 != param_length)
525 return -1;
526 rel = *u;
527 if (rel.rel_value_us > INT64_MAX)
528 rel.rel_value_us = INT64_MAX;
529 u_nbo = GNUNET_new (uint64_t);
530 scratch[0] = u_nbo;
531 *u_nbo = GNUNET_htonll (rel.rel_value_us);
532 param_values[0] = (void *) u_nbo;
533 param_lengths[0] = sizeof(uint64_t);
534 param_formats[0] = 1;
535 return 1;
536}
static mp_limb_t u[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
Time for relative time used by GNUnet, in microseconds.

References data, GNUNET_break, GNUNET_htonll(), GNUNET_new, GNUNET_TIME_Relative::rel_value_us, and u.

Referenced by GNUNET_PQ_query_param_relative_time().

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

◆ GNUNET_PQ_query_param_relative_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_relative_time ( const struct GNUNET_TIME_Relative x)

Generate query parameter for a relative time value.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 540 of file pq_query_helper.c.

541{
542 struct GNUNET_PQ_QueryParam res = {
543 .conv = &qconv_rel_time,
544 .data = x,
545 .size = sizeof(*x),
546 .num_params = 1
547 };
548
549 return res;
550}
static int qconv_rel_time(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_rel_time(), and res.

Here is the call graph for this function:

◆ qconv_abs_time()

static int qconv_abs_time ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 568 of file pq_query_helper.c.

577{
578 const struct GNUNET_TIME_Absolute *u = data;
579 struct GNUNET_TIME_Absolute abs;
580 uint64_t *u_nbo;
581
582 GNUNET_break (NULL == cls);
583 if (1 != param_length)
584 return -1;
585 abs = *u;
586 if (abs.abs_value_us > INT64_MAX)
587 abs.abs_value_us = INT64_MAX;
588 u_nbo = GNUNET_new (uint64_t);
589 scratch[0] = u_nbo;
590 *u_nbo = GNUNET_htonll (abs.abs_value_us);
591 param_values[0] = (void *) u_nbo;
592 param_lengths[0] = sizeof(uint64_t);
593 param_formats[0] = 1;
594 return 1;
595}
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_TIME_Absolute::abs_value_us, data, GNUNET_break, GNUNET_htonll(), GNUNET_new, and u.

Referenced by GNUNET_PQ_query_param_absolute_time().

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

◆ GNUNET_PQ_query_param_absolute_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time ( const struct GNUNET_TIME_Absolute x)

Generate query parameter for an absolute time value.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 599 of file pq_query_helper.c.

600{
601 struct GNUNET_PQ_QueryParam res = {
602 .conv = &qconv_abs_time,
603 .data = x,
604 .size = sizeof(*x),
605 .num_params = 1
606 };
607
608 return res;
609}
static int qconv_abs_time(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_abs_time(), and res.

Referenced by delete_old_block(), GNUNET_PQ_query_param_timestamp(), namecache_postgres_cache_block(), namecache_postgres_expire_blocks(), postgres_plugin_del(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), and postgres_plugin_put().

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

◆ GNUNET_PQ_query_param_absolute_time_nbo()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time_nbo ( const struct GNUNET_TIME_AbsoluteNBO x)

Generate query parameter for an absolute time value.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 613 of file pq_query_helper.c.

615{
617}
#define GNUNET_PQ_query_param_auto_from_type(x)
Generate fixed-size query parameter with size determined by variable type.
uint64_t abs_value_us__
The actual value (in network byte order).

References GNUNET_PQ_query_param_auto_from_type.

Referenced by GNUNET_PQ_query_param_timestamp_nbo().

Here is the caller graph for this function:

◆ GNUNET_PQ_query_param_timestamp()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp ( const struct GNUNET_TIME_Timestamp x)

Generate query parameter for a timestamp.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 621 of file pq_query_helper.c.

622{
624}
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x)
Generate query parameter for an absolute time value.
struct GNUNET_TIME_Absolute abs_time
The actual value.

References GNUNET_PQ_query_param_absolute_time().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_timestamp_nbo()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp_nbo ( const struct GNUNET_TIME_TimestampNBO x)

Generate query parameter for a timestamp in NBO.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
query parameter to use

Definition at line 628 of file pq_query_helper.c.

630{
632}
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x)
Generate query parameter for an absolute time value.
struct GNUNET_TIME_AbsoluteNBO abs_time_nbo
The actual value.

References GNUNET_PQ_query_param_absolute_time_nbo().

Here is the call graph for this function:

◆ qconv_array_cls_cleanup()

static void qconv_array_cls_cleanup ( void *  cls)
static

Callback to cleanup a qconv_array_cls to be used during GNUNET_PQ_cleanup_query_params_closures.

Definition at line 680 of file pq_query_helper.c.

681{
682 GNUNET_free (cls);
683}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

Referenced by query_param_array_generic().

Here is the caller graph for this function:

◆ qconv_array()

static int qconv_array ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters for arrays.

Note: the format for the encoding of arrays for libpq is not very well documented. We peeked into various sources (postgresql and libpqtypes) for guidance.

Parameters
clsClosure of type struct qconv_array_cls*
dataPointer to first element in the array
data_lenNumber of elements in array data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 705 of file pq_query_helper.c.

715{
716 struct qconv_array_cls *meta = cls;
717 size_t num = data_len;
718 size_t total_size;
719 const size_t *sizes;
720 bool same_sized;
721 size_t *string_lengths = NULL;
722 void *elements = NULL;
723 bool noerror = true;
724
725 (void) (param_length);
726 (void) (scratch_length);
727
728 GNUNET_assert (NULL != meta);
729 GNUNET_assert (num < INT_MAX);
730
731 sizes = meta->sizes;
732 same_sized = (0 != meta->same_size);
733
734#define RETURN_UNLESS(cond) \
735 do { \
736 if (! (cond)) \
737 { \
738 GNUNET_break ((cond)); \
739 noerror = false; \
740 goto DONE; \
741 } \
742 } while (0)
743
744 /* Calculate sizes and check bounds */
745 {
746 /* num * length-field */
747 size_t x = sizeof(uint32_t);
748 size_t y = x * num;
749 RETURN_UNLESS ((0 == num) || (y / num == x));
750
751 /* size of header */
752 total_size = x = sizeof(struct pq_array_header);
753 total_size += y;
754 RETURN_UNLESS (total_size >= x);
755
756 /* sizes of elements */
757 if (same_sized)
758 {
759 x = num * meta->same_size;
760 RETURN_UNLESS ((0 == num) || (x / num == meta->same_size));
761
762 y = total_size;
763 total_size += x;
764 RETURN_UNLESS (total_size >= y);
765 }
766 else /* sizes are different per element */
767 {
768 /* for an array of strings we need to get their length's first */
769 if (array_of_string == meta->typ)
770 {
771 string_lengths = GNUNET_new_array (num, size_t);
772
773 if (meta->continuous)
774 {
775 const char *ptr = data;
776 for (unsigned int i = 0; i < num; i++)
777 {
778 size_t len = strlen (ptr);
779 string_lengths[i] = len;
780 ptr += len + 1;
781 }
782 }
783 else
784 {
785 const char **str = (const char **) data;
786 for (unsigned int i = 0; i < num; i++)
787 string_lengths[i] = strlen (str[i]);
788 }
789
790 sizes = string_lengths;
791 }
792
793 for (unsigned int i = 0; i < num; i++)
794 {
795 x = total_size;
796 total_size += sizes[i];
797 RETURN_UNLESS (total_size >= x);
798 }
799 }
800
801 RETURN_UNLESS (total_size < INT_MAX);
802
803 elements = GNUNET_malloc (total_size);
804 }
805
806 /* Write data */
807 {
808 char *in = (char *) data;
809 char *out = elements;
810 size_t nullbyte = (array_of_string == meta->typ) ? 1 : 0;
811 struct pq_array_header h = {
812 .ndim = htonl (1), /* We only support one-dimensional arrays */
813 .has_null = htonl (0), /* We do not support NULL entries in arrays */
814 .lbound = htonl (1), /* Default start index value */
815 .dim = htonl (num),
816 .oid = htonl (meta->oid),
817 };
818
819 /* Write header */
820 GNUNET_memcpy (out, &h, sizeof(h));
821 out += sizeof(h);
822
823
824 /* Write elements */
825 for (unsigned int i = 0; i < num; i++)
826 {
827 size_t sz = same_sized ? meta->same_size : sizes[i];
828 size_t hsz = htonl (sz);
829
830 GNUNET_memcpy (out,
831 &hsz,
832 sizeof(hsz));
833 out += sizeof(uint32_t);
834
835 switch (meta->typ)
836 {
837 case array_of_bool:
838 {
839 GNUNET_assert (sizeof(bool) == sz);
840 *(bool *) out = (*(bool *) in);
841 in += sz;
842 break;
843 }
844 case array_of_uint16:
845 {
846 GNUNET_assert (sizeof(uint16_t) == sz);
847 *(uint16_t *) out = htons (*(uint16_t *) in);
848 in += sz;
849 break;
850 }
851 case array_of_uint32:
852 {
853 uint32_t v;
854 GNUNET_assert (sizeof(uint32_t) == sz);
855
856 v = htonl (*(uint32_t *) in);
857 GNUNET_memcpy (out,
858 &v,
859 sizeof(v));
860 in += sz;
861 break;
862 }
863 case array_of_uint64:
864 {
865 uint64_t tmp;
866 GNUNET_assert (sizeof(uint64_t) == sz);
867
868 tmp = GNUNET_htonll (*(uint64_t *) in);
869 GNUNET_memcpy (out,
870 &tmp,
871 sizeof(tmp));
872 in += sz;
873 break;
874 }
875 case array_of_byte:
876 case array_of_string:
877 {
878 const void *ptr;
879
880 if (meta->continuous)
881 {
882 ptr = in;
883 in += sz + nullbyte;
884 }
885 else
886 ptr = ((const void **) data)[i];
887
888 GNUNET_memcpy (out,
889 ptr,
890 sz);
891 break;
892 }
896 {
897 uint64_t val;
898
899 switch (meta->typ)
900 {
902 {
903 const struct GNUNET_TIME_Absolute *abs =
904 (const struct GNUNET_TIME_Absolute *) in;
905
906 GNUNET_assert (sizeof(struct GNUNET_TIME_Absolute) == sz);
907
908 if (! meta->continuous)
909 abs = ((const struct GNUNET_TIME_Absolute **) data)[i];
910
911 val = abs->abs_value_us;
912 break;
913 }
915 {
916 const struct GNUNET_TIME_Relative *rel =
917 (const struct GNUNET_TIME_Relative *) in;
918
919 GNUNET_assert (sizeof(struct GNUNET_TIME_Relative) == sz);
920
921 if (! meta->continuous)
922 rel = ((const struct GNUNET_TIME_Relative **) data)[i];
923
924 val = rel->rel_value_us;
925 break;
926 }
928 {
929 const struct GNUNET_TIME_Timestamp *ts =
930 (const struct GNUNET_TIME_Timestamp *) in;
931
932 GNUNET_assert (sizeof(struct GNUNET_TIME_Timestamp) == sz);
933
934 if (! meta->continuous)
935 ts = ((const struct GNUNET_TIME_Timestamp **) data)[i];
936
937 val = ts->abs_time.abs_value_us;
938 break;
939 }
940 default:
941 {
942 GNUNET_assert (0);
943 }
944 }
945
946 if (val > INT64_MAX)
947 val = INT64_MAX;
948
949 val = GNUNET_htonll (val);
950 GNUNET_memcpy (out,
951 &val,
952 sizeof(val));
953
954 if (meta->continuous)
955 in += sz;
956
957 break;
958 }
959 default:
960 {
961 GNUNET_assert (0);
962 break;
963 }
964 }
965 out += sz;
966 }
967 }
968
969 param_values[0] = elements;
970 param_lengths[0] = total_size;
971 param_formats[0] = 1;
972 scratch[0] = elements;
973
974DONE:
975 GNUNET_free (string_lengths);
976
977 if (noerror)
978 return 1;
979
980 return -1;
981}
#define INT_MAX
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
@ array_of_byte
Definition: pq.h:137
@ array_of_uint32
Definition: pq.h:135
@ array_of_string
Definition: pq.h:138
@ array_of_rel_time
Definition: pq.h:140
@ array_of_uint16
Definition: pq.h:134
@ array_of_uint64
Definition: pq.h:136
@ array_of_abs_time
Definition: pq.h:139
@ array_of_timestamp
Definition: pq.h:141
@ array_of_bool
Definition: pq.h:133
#define RETURN_UNLESS(cond)
uint64_t abs_value_us
The actual value.
uint64_t rel_value_us
The actual value.
Rounded time for timestamps used by GNUnet, in seconds.
the header for a postgresql array in binary format.
Definition: pq.h:151
Closure for the array type handlers.
const size_t * sizes
If not null, contains the array of sizes (the size of the array is the .size field in the ambient GNU...

References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, array_of_abs_time, array_of_bool, array_of_byte, array_of_rel_time, array_of_string, array_of_timestamp, array_of_uint16, array_of_uint32, array_of_uint64, data, GNUNET_assert, GNUNET_free, GNUNET_htonll(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new_array, h, INT_MAX, meta, GNUNET_TIME_Relative::rel_value_us, RETURN_UNLESS, and qconv_array_cls::sizes.

Referenced by query_param_array_generic().

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

◆ query_param_array_generic()

static struct GNUNET_PQ_QueryParam query_param_array_generic ( unsigned int  num,
bool  continuous,
const void *  elements,
const size_t *  sizes,
size_t  same_size,
enum array_types  typ,
Oid  oid 
)
static

Function to genreate a typ specific query parameter and corresponding closure.

Parameters
numNumber of elements in elements
continuousIf true, elements is an continuous array of data
elementsArray of num elements, either continuous or pointers
sizesArray of num sizes, one per element, may be NULL
same_sizeIf not 0, all elements in elements have this size
typSupported internal type of each element in elements
oidOid of the type to be used in Postgres
Returns
Query parameter

Definition at line 997 of file pq_query_helper.c.

1005{
1007
1008 meta->typ = typ;
1009 meta->oid = oid;
1010 meta->sizes = sizes;
1011 meta->same_size = same_size;
1012 meta->continuous = continuous;
1013
1014 {
1015 struct GNUNET_PQ_QueryParam res = {
1016 .conv = qconv_array,
1017 .conv_cls = meta,
1018 .conv_cls_cleanup = &qconv_array_cls_cleanup,
1019 .data = elements,
1020 .size = num,
1021 .num_params = 1,
1022 };
1023
1024 return res;
1025 }
1026}
uint32_t oid
Definition: gnunet_pq_lib.h:2
static void qconv_array_cls_cleanup(void *cls)
Callback to cleanup a qconv_array_cls to be used during GNUNET_PQ_cleanup_query_params_closures.
static int qconv_array(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters for arrays.
enum array_types typ
Type of the array elements.
size_t same_size
If size and c_sizes are NULL, this field defines the same size for each element in the array.
bool continuous
If true, the array parameter to the data pointer to the qconv_array is a continuous byte array of dat...

References qconv_array_cls::continuous, GNUNET_new, meta, oid, qconv_array(), qconv_array_cls_cleanup(), res, qconv_array_cls::same_size, GNUNET_PQ_QueryParam::size, qconv_array_cls::sizes, and qconv_array_cls::typ.

Referenced by GNUNET_PQ_query_param_array_abs_time(), GNUNET_PQ_query_param_array_bool(), GNUNET_PQ_query_param_array_bytes(), GNUNET_PQ_query_param_array_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_abs_time(), GNUNET_PQ_query_param_array_ptrs_bytes(), GNUNET_PQ_query_param_array_ptrs_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_rel_time(), GNUNET_PQ_query_param_array_ptrs_string(), GNUNET_PQ_query_param_array_ptrs_timestamp(), GNUNET_PQ_query_param_array_rel_time(), GNUNET_PQ_query_param_array_string(), GNUNET_PQ_query_param_array_timestamp(), GNUNET_PQ_query_param_array_uint16(), GNUNET_PQ_query_param_array_uint32(), and GNUNET_PQ_query_param_array_uint64().

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

◆ GNUNET_PQ_query_param_array_bool()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bool ( unsigned int  num,
const bool *  elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of bool in host byte order.

Parameters
numNumber of elements in elements
elementsContinuous array of num boolean elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1030 of file pq_query_helper.c.

1034{
1035 Oid oid;
1036
1039 "bool",
1040 &oid));
1041 return query_param_array_generic (num,
1042 true,
1043 elements,
1044 NULL,
1045 sizeof(bool),
1047 oid);
1048}
static struct GNUNET_FS_DirectoryBuilder * db
Definition: gnunet-search.c:97
enum GNUNET_GenericReturnValue GNUNET_PQ_get_oid_by_name(struct GNUNET_PQ_Context *db, const char *name, Oid *oid)
Returns the oid for a given datatype by name.
Definition: pq_connect.c:326
@ GNUNET_OK
static struct GNUNET_PQ_QueryParam query_param_array_generic(unsigned int num, bool continuous, const void *elements, const size_t *sizes, size_t same_size, enum array_types typ, Oid oid)
Function to genreate a typ specific query parameter and corresponding closure.

References array_of_bool, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_uint16()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint16 ( unsigned int  num,
const uint16_t *  elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of uint16_t in host byte order.

Note that the (unsigend) elements are not checked to wrap over INT2_MAX

Parameters
numNumber of elements in elements
elementsContinuous array of num uint16 elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1052 of file pq_query_helper.c.

1056{
1057 Oid oid;
1058
1061 "int2",
1062 &oid));
1063 return query_param_array_generic (num,
1064 true,
1065 elements,
1066 NULL,
1067 sizeof(uint16_t),
1069 oid);
1070}

References array_of_uint16, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_uint32()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint32 ( unsigned int  num,
const uint32_t *  elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of uint32_t in host byte order.

Note that the (unsigend) elements are not checked to wrap over INT4_MAX

Parameters
numNumber of elements in elements
elementsContinuous Array of num uint32_t elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1074 of file pq_query_helper.c.

1078{
1079 Oid oid;
1080
1083 "int4",
1084 &oid));
1085 return query_param_array_generic (num,
1086 true,
1087 elements,
1088 NULL,
1089 sizeof(uint32_t),
1091 oid);
1092}

References array_of_uint32, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_uint64()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint64 ( unsigned int  num,
const uint64_t *  elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of uint64 in host byte order.

Note that the (unsigend) elements are not checked to wrap over INT8_MAX

Parameters
numNumber of elements in elements
elementsContinuous array of num uint64_t elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1096 of file pq_query_helper.c.

1100{
1101 Oid oid;
1102
1105 "int8",
1106 &oid));
1107 return query_param_array_generic (num,
1108 true,
1109 elements,
1110 NULL,
1111 sizeof(uint64_t),
1113 oid);
1114}

References array_of_uint64, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_bytes()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes ( unsigned int  num,
const void *  elements,
const size_t *  sizes,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of buffers elements, each of corresponding size given in sizes.

Parameters
numNumber of elements in elements
elementsContinous array of num buffers, each of corresponding size given in sizes.
sizesPointer to sizes in bytes of each element in elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1118 of file pq_query_helper.c.

1123{
1124 Oid oid;
1125
1128 "bytea",
1129 &oid));
1130 return query_param_array_generic (num,
1131 true,
1132 elements,
1133 sizes,
1134 0,
1136 oid);
1137}

References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_bytes()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes ( unsigned int  num,
const void *  elements[static num],
const size_t *  sizes,
struct GNUNET_PQ_Context db 
)

Definition at line 1141 of file pq_query_helper.c.

1146{
1147 Oid oid;
1148
1151 "bytea",
1152 &oid));
1153 return query_param_array_generic (num,
1154 false,
1155 elements,
1156 sizes,
1157 0,
1159 oid);
1160}

References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_bytes_same_size()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes_same_size ( unsigned int  num,
const void *  elements,
size_t  same_size,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of buffers elements, each of the same size size.

Parameters
numNumber of elements in elements
elementsContinous array of num buffers, each with the same size same_size
same_sizeSize in bytes of each element in elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1164 of file pq_query_helper.c.

1169{
1170 Oid oid;
1171
1174 "bytea",
1175 &oid));
1176 return query_param_array_generic (num,
1177 true,
1178 elements,
1179 NULL,
1180 same_size,
1182 oid);
1183}

References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_bytes_same_size()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( unsigned int  num,
const void *  elements[static num],
size_t  same_size,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of pointers to buffers elements, each of the same size size.

Parameters
numNumber of elements in elements
elementsArray of num pointers to buffers, each with the same size same_size
same_sizeSize in bytes of each element in elements
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1187 of file pq_query_helper.c.

1192{
1193 Oid oid;
1194
1197 "bytea",
1198 &oid));
1199 return query_param_array_generic (num,
1200 false,
1201 elements,
1202 NULL,
1203 same_size,
1205 oid);
1206}

References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_string()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_string ( unsigned int  num,
const char *  elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of strings (continuous)

Parameters
numNumber of elements in elements
elementsArray of num continuous strings (zero-terminated each)
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1210 of file pq_query_helper.c.

1214{
1215 Oid oid;
1216
1219 "text",
1220 &oid));
1221 return query_param_array_generic (num,
1222 true,
1223 elements,
1224 NULL,
1225 0,
1227 oid);
1228}

References array_of_string, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_string()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_string ( unsigned int  num,
const char *  elements[static num],
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of strings (pointers)

Parameters
numNumber of elements in elements
elementsArray of num pointer to strings
dbDatabase context, needed for database-depending encoding of elements
Returns
query parameter to use

Definition at line 1232 of file pq_query_helper.c.

1236{
1237 Oid oid;
1238
1241 "text",
1242 &oid));
1243 return query_param_array_generic (num,
1244 false,
1245 elements,
1246 NULL,
1247 0,
1249 oid);
1250}

References array_of_string, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_abs_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_abs_time ( unsigned int  num,
const struct GNUNET_TIME_Absolute elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of absolute time stamps (continuous)

Parameters
numNumber of elements in elements
elementsArray of num absolute timestamps
Returns
query parameter to use

Definition at line 1254 of file pq_query_helper.c.

1258{
1259 Oid oid;
1260
1263 "int8",
1264 &oid));
1265 return query_param_array_generic (num,
1266 true,
1267 elements,
1268 NULL,
1269 sizeof(struct GNUNET_TIME_Absolute),
1271 oid);
1272}

References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_abs_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_abs_time ( unsigned int  num,
const struct GNUNET_TIME_Absolute elements[],
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of absolute time stamps (pointers)

Parameters
numNumber of elements in elements
elementsArray of num pointers to absolute timestamps
Returns
query parameter to use

Definition at line 1276 of file pq_query_helper.c.

1280{
1281 Oid oid;
1282
1285 "int8",
1286 &oid));
1287 return query_param_array_generic (num,
1288 false,
1289 elements,
1290 NULL,
1291 sizeof(struct GNUNET_TIME_Absolute),
1293 oid);
1294}

References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_rel_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_rel_time ( unsigned int  num,
const struct GNUNET_TIME_Relative elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of relative time stamps (continuous)

Parameters
numNumber of elements in elements
elementsArray of num relative timestamps
Returns
query parameter to use

Definition at line 1298 of file pq_query_helper.c.

1302{
1303 Oid oid;
1304
1307 "int8",
1308 &oid));
1309 return query_param_array_generic (num,
1310 true,
1311 elements,
1312 NULL,
1313 sizeof(struct GNUNET_TIME_Relative),
1315 oid);
1316}

References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_rel_time()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_rel_time ( unsigned int  num,
const struct GNUNET_TIME_Relative elements[],
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of relative time stamps (pointers)

Parameters
numNumber of elements in elements
elementsArray of num pointers to relative timestamps
Returns
query parameter to use

Definition at line 1320 of file pq_query_helper.c.

1324{
1325 Oid oid;
1326
1329 "int8",
1330 &oid));
1331 return query_param_array_generic (num,
1332 false,
1333 elements,
1334 NULL,
1335 sizeof(struct GNUNET_TIME_Relative),
1337 oid);
1338}

References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_timestamp()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_timestamp ( unsigned int  num,
const struct GNUNET_TIME_Timestamp elements,
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of time stamps (continuous)

Parameters
numNumber of elements in elements
elementsArray of num timestamps
Returns
query parameter to use

Definition at line 1342 of file pq_query_helper.c.

1346{
1347 Oid oid;
1348
1351 "int8",
1352 &oid));
1353 return query_param_array_generic (num,
1354 true,
1355 elements,
1356 NULL,
1357 sizeof(struct GNUNET_TIME_Timestamp),
1359 oid);
1360}

References array_of_timestamp, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ GNUNET_PQ_query_param_array_ptrs_timestamp()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_timestamp ( unsigned int  num,
const struct GNUNET_TIME_Timestamp elements[],
struct GNUNET_PQ_Context db 
)

Generate query parameter for an array of time stamps (pointers)

Parameters
numNumber of elements in elements
elementsArray of num pointers to relative timestamps
Returns
query parameter to use

Definition at line 1364 of file pq_query_helper.c.

1368{
1369 Oid oid;
1370
1373 "int8",
1374 &oid));
1375 return query_param_array_generic (num,
1376 false,
1377 elements,
1378 NULL,
1379 sizeof(struct GNUNET_TIME_Timestamp),
1381 oid);
1382}

References array_of_timestamp, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().

Here is the call graph for this function:

◆ qconv_blind_sign_pub()

static int qconv_blind_sign_pub ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 1400 of file pq_query_helper.c.

1409{
1410 const struct GNUNET_CRYPTO_BlindSignPublicKey *public_key = data;
1411 size_t tlen;
1412 size_t len;
1413 uint32_t be;
1414 char *buf;
1415 void *tbuf;
1416
1417 (void) cls;
1418 (void) data_len;
1419 GNUNET_assert (1 == param_length);
1420 GNUNET_assert (scratch_length > 0);
1421 GNUNET_break (NULL == cls);
1422 be = htonl ((uint32_t) public_key->cipher);
1423 switch (public_key->cipher)
1424 {
1427 public_key->details.rsa_public_key,
1428 &tbuf);
1429 break;
1431 tlen = sizeof (public_key->details.cs_public_key);
1432 break;
1433 default:
1434 GNUNET_assert (0);
1435 }
1436 len = tlen + sizeof (be);
1437 buf = GNUNET_malloc (len);
1438 GNUNET_memcpy (buf,
1439 &be,
1440 sizeof (be));
1441 switch (public_key->cipher)
1442 {
1444 GNUNET_memcpy (&buf[sizeof (be)],
1445 tbuf,
1446 tlen);
1447 GNUNET_free (tbuf);
1448 break;
1450 GNUNET_memcpy (&buf[sizeof (be)],
1451 &public_key->details.cs_public_key,
1452 tlen);
1453 break;
1454 default:
1455 GNUNET_assert (0);
1456 }
1457
1458 scratch[0] = buf;
1459 param_values[0] = (void *) buf;
1460 param_lengths[0] = len;
1461 param_formats[0] = 1;
1462 return 1;
1463}
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@16 details
Details, depending on cipher.
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, data, GNUNET_CRYPTO_BlindSignPublicKey::details, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, and GNUNET_CRYPTO_BlindSignPublicKey::rsa_public_key.

Referenced by GNUNET_PQ_query_param_blind_sign_pub().

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

◆ GNUNET_PQ_query_param_blind_sign_pub()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_pub ( const struct GNUNET_CRYPTO_BlindSignPublicKey pub)

Generate query parameter for a blind sign public key of variable size.

Generate query parameter for a blind sign public key.

Parameters
pubpointer to the query parameter to pass

Definition at line 1472 of file pq_query_helper.c.

1474{
1475 struct GNUNET_PQ_QueryParam res = {
1476 .conv = &qconv_blind_sign_pub,
1477 .data = pub,
1478 .num_params = 1
1479 };
1480
1481 return res;
1482}
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static int qconv_blind_sign_pub(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References pub, qconv_blind_sign_pub(), and res.

Here is the call graph for this function:

◆ qconv_blind_sign_priv()

static int qconv_blind_sign_priv ( void *  cls,
const void *  data,
size_t  data_len,
void *  param_values[],
int  param_lengths[],
int  param_formats[],
unsigned int  param_length,
void *  scratch[],
unsigned int  scratch_length 
)
static

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
datapointer to input argument
data_lennumber of bytes in data (if applicable)
[out]param_valuesSQL data to set
[out]param_lengthsSQL length data to set
[out]param_formatsSQL format data to set
param_lengthnumber of entries available in the param_values, param_lengths and param_formats arrays
[out]scratchbuffer for dynamic allocations (to be done via GNUNET_malloc()
scratch_lengthnumber of entries left in scratch
Returns
-1 on error, number of offsets used in scratch otherwise

Definition at line 1500 of file pq_query_helper.c.

1509{
1510 const struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key = data;
1511 size_t tlen;
1512 size_t len;
1513 uint32_t be;
1514 char *buf;
1515 void *tbuf;
1516
1517 (void) cls;
1518 (void) data_len;
1519 GNUNET_assert (1 == param_length);
1520 GNUNET_assert (scratch_length > 0);
1521 GNUNET_break (NULL == cls);
1522 be = htonl ((uint32_t) private_key->cipher);
1523 switch (private_key->cipher)
1524 {
1527 private_key->details.rsa_private_key,
1528 &tbuf);
1529 break;
1531 tlen = sizeof (private_key->details.cs_private_key);
1532 break;
1533 default:
1534 GNUNET_assert (0);
1535 }
1536 len = tlen + sizeof (be);
1537 buf = GNUNET_malloc (len);
1538 GNUNET_memcpy (buf,
1539 &be,
1540 sizeof (be));
1541 switch (private_key->cipher)
1542 {
1544 GNUNET_memcpy (&buf[sizeof (be)],
1545 tbuf,
1546 tlen);
1547 GNUNET_free (tbuf);
1548 break;
1550 GNUNET_memcpy (&buf[sizeof (be)],
1551 &private_key->details.cs_private_key,
1552 tlen);
1553 break;
1554 default:
1555 GNUNET_assert (0);
1556 }
1557
1558 scratch[0] = buf;
1559 param_values[0] = (void *) buf;
1560 param_lengths[0] = len;
1561 param_formats[0] = 1;
1562 return 1;
1563}
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition: crypto_rsa.c:181
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@17 details
Details, depending on cipher.

References GNUNET_CRYPTO_BlindSignPrivateKey::cipher, GNUNET_CRYPTO_BlindSignPrivateKey::cs_private_key, data, GNUNET_CRYPTO_BlindSignPrivateKey::details, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_RSA, GNUNET_CRYPTO_rsa_private_key_encode(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, and GNUNET_CRYPTO_BlindSignPrivateKey::rsa_private_key.

Referenced by GNUNET_PQ_query_param_blind_sign_priv().

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

◆ GNUNET_PQ_query_param_blind_sign_priv()

struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_priv ( const struct GNUNET_CRYPTO_BlindSignPrivateKey priv)

Generate query parameter for a blind sign private key of variable size.

Parameters
privpointer to the query parameter to pass

Definition at line 1572 of file pq_query_helper.c.

1574{
1575 struct GNUNET_PQ_QueryParam res = {
1576 .conv = &qconv_blind_sign_priv,
1577 .data = priv,
1578 .num_params = 1
1579 };
1580
1581 return res;
1582}
static int qconv_blind_sign_priv(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.

References qconv_blind_sign_priv(), and res.

Here is the call graph for this function: