diff options
Diffstat (limited to 'src/pq/pq_result_helper.c')
-rw-r--r-- | src/pq/pq_result_helper.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 9bd3fdb49..915aad144 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c @@ -1249,6 +1249,30 @@ extract_array_generic ( } return GNUNET_OK; + case TALER_PQ_array_of_hash_code: + if (NULL != dst_size) + *dst_size = sizeof(struct GNUNET_HashCode) * (header.dim); + out = GNUNET_new_array (header.dim, + struct GNUNET_HashCode); + *((void **) dst) = out; + for (uint32_t i = 0; i < header.dim; i++) + { + uint32_t val; + size_t sz; + + GNUNET_memcpy (&val, + in, + sizeof(val)); + sz = ntohl (val); + FAIL_IF (sz != sizeof(struct GNUNET_HashCode)); + in += sizeof(uint32_t); + *(struct GNUNET_HashCode *) out = + *(struct GNUNET_HashCode *) in; + in += sz; + out += sz; + } + return GNUNET_OK; + case TALER_PQ_array_of_blinded_coin_hash: if (NULL != dst_size) *dst_size = sizeof(struct TALER_BlindedCoinHashP) * (header.dim); @@ -1504,4 +1528,34 @@ TALER_PQ_result_spec_array_amount ( } +struct GNUNET_PQ_ResultSpec +TALER_PQ_result_spec_array_hash_code ( + struct GNUNET_PQ_Context *db, + const char *name, + size_t *num, + struct GNUNET_HashCode **hashes) +{ + struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); + + info->num = num; + info->typ = TALER_PQ_array_of_hash_code; + info->db = db; + GNUNET_assert (GNUNET_OK == + GNUNET_PQ_get_oid_by_name (db, + "gnunet_hashcode", + &info->oid)); + + struct GNUNET_PQ_ResultSpec res = { + .conv = extract_array_generic, + .cleaner = array_cleanup, + .dst = (void *) hashes, + .fname = name, + .cls = info, + }; + return res; + + +} + + /* end of pq_result_helper.c */ |