97 *((
void **)
dst) = NULL;
112 len = PQgetlength (
result,
121 *((
void **)
dst) = idst;
137 .dst = (
void *) (
dst),
178 "Result does not have field %s\n",
188 len = PQgetlength (
result,
194 "Expected %u bytes for field `%s', got %u\n",
270 len = PQgetlength (
result,
365 len = PQgetlength (
result,
460 len = PQgetlength (
result,
554 len = PQgetlength (
result,
557 if (
sizeof (uint8_t) != len)
562 res = (
const uint8_t *) PQgetvalue (
result,
627 if (
sizeof(int64_t) !=
704 if (
sizeof(int64_t) !=
744 &at->abs_value_us__);
794 if (
sizeof(int64_t) !=
913 uint16_t *udst =
dst;
935 if (
sizeof(uint16_t) !=
946 *udst = ntohs (*
res);
987 uint32_t *udst =
dst;
1009 if (
sizeof(uint32_t) !=
1020 *udst = ntohl (*
res);
1031 .dst = (
void *) u32,
1061 uint64_t *udst =
dst;
1062 const uint64_t *
res;
1066 fnum = PQfnumber (
result,
1071 "Field %s missing in result\n",
1087 if (
sizeof(uint64_t) !=
1094 "Got length %u for field `%s'\n",
1115 .dst = (
void *) u64,
1145 int64_t *udst =
dst;
1150 fnum = PQfnumber (
result,
1155 "Field %s missing in result\n",
1171 if (
sizeof(int64_t) !=
1178 "Got length %u for field `%s'\n",
1199 .dst = (
void *) i64,
1264 *((
void **) dst) = NULL;
1266 #define FAIL_IF(cond) \
1270 GNUNET_break (! (cond)); \
1275 col_num = PQfnumber (
result, fname);
1278 data_sz = PQgetlength (
result, row, col_num);
1281 if (
sizeof(header) > (
size_t) data_sz)
1287 FAIL_IF (
sizeof(uint32_t) > (
size_t) data_sz);
1295 FAIL_IF (
sizeof(header) > (
size_t) data_sz);
1302 header.
ndim = ntohl (
h->ndim);
1304 header.
oid = ntohl (
h->oid);
1305 header.
dim = ntohl (
h->dim);
1306 header.
lbound = ntohl (
h->lbound);
1315 if (NULL !=
info->num)
1319 char *in =
data +
sizeof(header);
1324 if (NULL != dst_size)
1325 *dst_size =
sizeof(bool) * (header.
dim);
1327 *((
void **) dst) = out;
1328 for (uint32_t i = 0; i < header.
dim; i++)
1330 size_t sz = ntohl (*(uint32_t *) in);
1332 in +=
sizeof(uint32_t);
1333 *(
bool *) out = *(
bool *) in;
1340 if (NULL != dst_size)
1341 *dst_size =
sizeof(uint16_t) * (header.
dim);
1343 *((
void **) dst) = out;
1344 for (uint32_t i = 0; i < header.
dim; i++)
1346 size_t sz = ntohl (*(uint32_t *) in);
1347 FAIL_IF (sz !=
sizeof(uint16_t));
1348 in +=
sizeof(uint32_t);
1349 *(uint16_t *) out = ntohs (*(uint16_t *) in);
1356 if (NULL != dst_size)
1357 *dst_size =
sizeof(uint32_t) * (header.
dim);
1359 *((
void **) dst) = out;
1360 for (uint32_t i = 0; i < header.
dim; i++)
1362 size_t sz = ntohl (*(uint32_t *) in);
1363 FAIL_IF (sz !=
sizeof(uint32_t));
1364 in +=
sizeof(uint32_t);
1365 *(uint32_t *) out = ntohl (*(uint32_t *) in);
1372 if (NULL != dst_size)
1373 *dst_size =
sizeof(uint64_t) * (header.
dim);
1375 *((
void **) dst) = out;
1376 for (uint32_t i = 0; i < header.
dim; i++)
1378 size_t sz = ntohl (*(uint32_t *) in);
1379 FAIL_IF (sz !=
sizeof(uint64_t));
1380 in +=
sizeof(uint32_t);
1388 if (NULL != dst_size)
1391 *((
void **) dst) = out;
1392 for (uint32_t i = 0; i < header.
dim; i++)
1394 size_t sz = ntohl (*(uint32_t *) in);
1395 FAIL_IF (sz !=
sizeof(uint64_t));
1396 in +=
sizeof(uint32_t);
1405 if (NULL != dst_size)
1409 *((
void **) dst) = out;
1410 for (uint32_t i = 0; i < header.
dim; i++)
1412 size_t sz = ntohl (*(uint32_t *) in);
1413 FAIL_IF (sz !=
sizeof(uint64_t));
1414 in +=
sizeof(uint32_t);
1423 if (NULL != dst_size)
1427 *((
void **) dst) = out;
1428 for (uint32_t i = 0; i < header.
dim; i++)
1430 size_t sz = ntohl (*(uint32_t *) in);
1431 FAIL_IF (sz !=
sizeof(uint64_t));
1432 in +=
sizeof(uint32_t);
1441 if (0 ==
info->same_size)
1451 char *ptr =
data +
sizeof(header);
1452 for (uint32_t i = 0; i < header.
dim; i++)
1456 sz = ntohl (*(uint32_t *) ptr);
1457 total += sz + (is_string ? 1 : 0);
1458 ptr +=
sizeof(uint32_t);
1461 if ((! is_string) &&
1462 (0 ==
info->same_size))
1463 (*
info->sizes)[i] = sz;
1466 (sz !=
info->same_size));
1471 if (NULL != dst_size)
1477 *((
void **) dst) = out;
1480 for (uint32_t i = 0; i < header.
dim; i++)
1482 size_t sz = ntohl (*(uint32_t *) in);
1483 in +=
sizeof(uint32_t);
1518 (0 ==
info->same_size) &&
1519 (NULL !=
info->sizes))
1549 .dst = (
void *)
dst,
1579 .dst = (
void *)
dst,
1609 .dst = (
void *)
dst,
1638 .dst = (
void *)
dst,
1666 .dst = (
void *)
dst,
1695 .dst = (
void *)
dst,
1725 .dst = (
void *)
dst,
1757 .dst = (
void *)
dst,
1789 .dst = (
void *)
dst,
1819 .dst = (
void *)
dst,
1858 fnum = PQfnumber (
result,
1872 len = PQgetlength (
result,
1878 if (len <
sizeof (be))
1889 tmp->
cipher = ntohl (be);
1962 .dst = (
void *)
pub,
2000 fnum = PQfnumber (
result,
2014 len = PQgetlength (
result,
2020 if (len <
sizeof (be))
2031 tmp->
cipher = ntohl (be);
2098 .dst = (
void *) priv,
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static char * data
The data to insert into the dht.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_FS_DirectoryBuilder * db
static struct GNUNET_SCHEDULER_Task * t
Main task.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
helper functions for Postgres DB interactions
#define GNUNET_PQ_result_spec_auto_from_type(name, dst)
We expect a fixed-size result, with size determined by the type of * dst
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.
Functions related to time.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
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.
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.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
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.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
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.
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.
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
#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.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton(struct GNUNET_TIME_Timestamp t)
Convert timestamp to network byte order.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static unsigned int size
Size of the "table".
shared internal data structures of libgnunetpq
array_types
Internal types that are supported as array types.
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.
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 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 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_uint32(const char *name, uint32_t *u32)
uint32_t 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_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_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.
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.
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 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_array_timestamp(struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Timestamp **dst)
array of 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.
static void clean_rsa_public_key(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
static void clean_varsize_blob(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
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_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.
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_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_uint64(const char *name, uint64_t *u64)
uint64_t expected.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string(const char *name, char **dst)
0-terminated string expected.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_priv(const char *name, struct GNUNET_CRYPTO_BlindSignPrivateKey **priv)
Blind sign private key expected.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_pub(const char *name, struct GNUNET_CRYPTO_BlindSignPublicKey **pub)
Blind sign public key expected.
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.
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_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time expected.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int64(const char *name, int64_t *i64)
int64_t expected.
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_uint16(const char *name, uint16_t *u16)
uint16_t 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_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.
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_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.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp(const char *name, struct GNUNET_TIME_Timestamp *at)
Timestamp expected.
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_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_rsa_public_key(const char *name, struct GNUNET_CRYPTO_RsaPublicKey **rsa)
RSA public key expected.
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_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.
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.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
RSA signature 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.
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_priv(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
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.
static void array_cleanup(void *cls, void *rd)
Cleanup of the data and closure of an array spec.
static void clean_rsa_signature(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@17 details
Details, depending on cipher.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@16 details
Details, depending on cipher.
unsigned int rc
Reference counter.
struct GNUNET_HashCode pub_key_hash
Hash of the public key.
struct GNUNET_CRYPTO_CsPublicKey cs_public_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
struct GNUNET_CRYPTO_RsaPublicKey * rsa_public_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
The public information of an RSA key pair.
Handle to Postgres database.
Description of a DB result cell.
const char * fname
Field name of the desired result.
bool * is_null
Points to a location where we should store "true" if the result found is NULL, and otherwise "false".
void * dst
Destination for the data.
bool is_nullable
True if NULL is allowed for a value in the database.
void * cls
Closure for conv and cleaner.
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...
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Time for timestamps used by GNUnet, in seconds and in network byte order.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.
Closure for the array result specifications.