From d15fd5add80707b30b874ecb207e2dcad29692cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 28 Nov 2023 15:38:07 +0100 Subject: [pq] add support for array of struct GNUNET_HashCode --- src/pq/pq_query_helper.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src/pq/pq_query_helper.c') diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index f66844515..24bf054da 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c @@ -846,14 +846,14 @@ qconv_array ( same_sized = (0 != meta->same_size); #define RETURN_UNLESS(cond) \ - do { \ - if (! (cond)) \ - { \ - GNUNET_break ((cond)); \ - noerror = false; \ - goto DONE; \ - } \ - } while (0) + do { \ + if (! (cond)) \ + { \ + GNUNET_break ((cond)); \ + noerror = false; \ + goto DONE; \ + } \ + } while (0) /* Calculate sizes and check bounds */ { @@ -1037,6 +1037,15 @@ qconv_array ( sizeof(struct TALER_DenominationHashP)); break; } + case TALER_PQ_array_of_hash_code: + { + const struct GNUNET_HashCode *hashes = data; + + GNUNET_memcpy (out, + &hashes[i], + sizeof(struct GNUNET_HashCode)); + break; + } default: { GNUNET_assert (0); @@ -1170,6 +1179,26 @@ TALER_PQ_query_param_array_denom_hash ( } +struct GNUNET_PQ_QueryParam +TALER_PQ_query_param_array_hash_code ( + size_t num, + const struct GNUNET_HashCode *hashes, + struct GNUNET_PQ_Context *db) +{ + Oid oid; + GNUNET_assert (GNUNET_OK == + GNUNET_PQ_get_oid_by_name (db, "gnunet_hashcode", &oid)); + return query_param_array_generic (num, + true, + hashes, + NULL, + sizeof(struct GNUNET_HashCode), + TALER_PQ_array_of_hash_code, + oid, + NULL); +} + + struct GNUNET_PQ_QueryParam TALER_PQ_query_param_array_amount ( size_t num, -- cgit v1.2.3