93 *((
void **) dst) = NULL;
95 fnum = PQfnumber (result,
102 if (PQgetisnull (result,
111 len = PQgetlength (result,
114 res = PQgetvalue (result,
120 *((
void **) dst) = idst;
136 (
void *) (
dst), 0,
name, sptr };
168 fnum = PQfnumber (result,
174 "Result does not have field %s\n",
178 if (PQgetisnull (result,
188 len = PQgetlength (result,
191 if (*dst_size != len)
194 "Expected %u bytes for field `%s', got %u\n",
195 (
unsigned int) *dst_size,
201 res = PQgetvalue (result,
254 fnum = PQfnumber (result,
261 if (PQgetisnull (result,
270 len = PQgetlength (result,
273 res = PQgetvalue (result,
317 (
void *) rsa, 0, name, NULL };
351 fnum = PQfnumber (result,
358 if (PQgetisnull (result,
367 len = PQgetlength (result,
370 res = PQgetvalue (result,
414 (
void *) sig, 0, (name), NULL };
448 fnum = PQfnumber (result,
455 if (PQgetisnull (result,
464 len = PQgetlength (result,
467 res = PQgetvalue (result,
511 (
void *)
dst, 0, (name), NULL };
543 fnum = PQfnumber (result,
550 if (PQgetisnull (result,
563 if (
sizeof(int64_t) !=
571 res = (int64_t *) PQgetvalue (result,
626 fnum = PQfnumber (result,
633 if (PQgetisnull (result,
646 if (
sizeof(int64_t) !=
654 res = (int64_t *) PQgetvalue (result,
673 (
void *) at,
sizeof(*at), (
name), NULL };
711 uint16_t *udst =
dst;
716 fnum = PQfnumber (result,
723 if (PQgetisnull (result,
731 if (
sizeof(uint16_t) != *dst_size)
736 if (
sizeof(uint16_t) !=
744 res = (uint16_t *) PQgetvalue (result,
747 *udst = ntohs (*res);
760 (
void *) u16,
sizeof(*u16), (
name), NULL };
787 uint32_t *udst =
dst;
792 fnum = PQfnumber (result,
799 if (PQgetisnull (result,
807 if (
sizeof(uint32_t) != *dst_size)
812 if (
sizeof(uint32_t) !=
820 res = (uint32_t *) PQgetvalue (result,
823 *udst = ntohl (*res);
836 (
void *) u32,
sizeof(*u32), (
name), NULL };
863 uint64_t *udst =
dst;
868 fnum = PQfnumber (result,
873 "Field %s missing in result\n",
878 if (PQgetisnull (result,
886 if (
sizeof(uint64_t) != *dst_size)
891 if (
sizeof(uint64_t) !=
899 res = (uint64_t *) PQgetvalue (result,
915 (
void *) u64,
sizeof(*u64), (
name), NULL
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_string(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
uint64_t rel_value_us
The actual value.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint16(const char *name, uint16_t *u16)
uint16_t expected.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time_nbo(const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time expected.
const char * fname
Field name of the desired result.
Description of a DB result cell.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int 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.
bool is_nullable
True if NULL is allowed for a value in the database.
static void clean_rsa_signature(void *cls, void *rd)
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
The public information of an RSA key pair.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int 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_uint64(const char *name, uint64_t *u64)
uint64_t expected.
static int extract_varsize_blob(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
RSA signature expected.
void * cls
Closure for conv and cleaner.
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_fixed_size(const char *name, void *dst, size_t dst_size)
Fixed-size result expected.
static int 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.
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. ...
static int 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.
static int result
Global testing status.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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...
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string(const char *name, char **dst)
0-terminated string expected.
bool * is_null
Points to a location where we should store "true" if the result found is NULL, and otherwise "false"...
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.
#define GNUNET_PQ_result_spec_auto_from_type(name, dst)
We expect a fixed-size result, with size determined by the type of * dst
static int 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.
helper functions for Postgres DB interactions
static int extract_rsa_signature(void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst)
Extract data from a Postgres database result at row row.
static void clean_rsa_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.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
static int 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_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static int 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.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_variable_size(const char *name, void **dst, size_t *sptr)
Variable-size result expected.
Time for absolute times used by GNUnet, in microseconds.
void * dst
Destination for the data.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time expected.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time expected.
static int 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.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...