aboutsummaryrefslogtreecommitdiff
path: root/src/pq/pq_result_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pq/pq_result_helper.c')
-rw-r--r--src/pq/pq_result_helper.c101
1 files changed, 18 insertions, 83 deletions
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index f764593b0..546822e45 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2014, 2015, 2016 GNUnet e.V. 3 Copyright (C) 2014, 2015, 2016, 2020 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -27,6 +27,19 @@
27#include "gnunet_pq_lib.h" 27#include "gnunet_pq_lib.h"
28 28
29 29
30struct GNUNET_PQ_ResultSpec
31GNUNET_PQ_result_spec_allow_null (struct GNUNET_PQ_ResultSpec rs,
32 bool *is_null)
33{
34 struct GNUNET_PQ_ResultSpec rsr;
35
36 rsr = rs;
37 rsr.is_nullable = true;
38 rsr.is_null = is_null;
39 return rsr;
40}
41
42
30/** 43/**
31 * Function called to clean up memory allocated 44 * Function called to clean up memory allocated
32 * by a #GNUNET_PQ_ResultConverter. 45 * by a #GNUNET_PQ_ResultConverter.
@@ -112,14 +125,6 @@ extract_varsize_blob (void *cls,
112} 125}
113 126
114 127
115/**
116 * Variable-size result expected.
117 *
118 * @param name name of the field in the table
119 * @param[out] dst where to store the result, allocated
120 * @param[out] sptr where to store the size of @a dst
121 * @return array entry for the result specification to use
122 */
123struct GNUNET_PQ_ResultSpec 128struct GNUNET_PQ_ResultSpec
124GNUNET_PQ_result_spec_variable_size (const char *name, 129GNUNET_PQ_result_spec_variable_size (const char *name,
125 void **dst, 130 void **dst,
@@ -196,14 +201,6 @@ extract_fixed_blob (void *cls,
196} 201}
197 202
198 203
199/**
200 * Fixed-size result expected.
201 *
202 * @param name name of the field in the table
203 * @param[out] dst where to store the result
204 * @param dst_size number of bytes in @a dst
205 * @return array entry for the result specification to use
206 */
207struct GNUNET_PQ_ResultSpec 204struct GNUNET_PQ_ResultSpec
208GNUNET_PQ_result_spec_fixed_size (const char *name, 205GNUNET_PQ_result_spec_fixed_size (const char *name,
209 void *dst, 206 void *dst,
@@ -301,13 +298,6 @@ clean_rsa_public_key (void *cls,
301} 298}
302 299
303 300
304/**
305 * RSA public key expected.
306 *
307 * @param name name of the field in the table
308 * @param[out] rsa where to store the result
309 * @return array entry for the result specification to use
310 */
311struct GNUNET_PQ_ResultSpec 301struct GNUNET_PQ_ResultSpec
312GNUNET_PQ_result_spec_rsa_public_key (const char *name, 302GNUNET_PQ_result_spec_rsa_public_key (const char *name,
313 struct GNUNET_CRYPTO_RsaPublicKey **rsa) 303 struct GNUNET_CRYPTO_RsaPublicKey **rsa)
@@ -405,13 +395,6 @@ clean_rsa_signature (void *cls,
405} 395}
406 396
407 397
408/**
409 * RSA signature expected.
410 *
411 * @param name name of the field in the table
412 * @param[out] sig where to store the result;
413 * @return array entry for the result specification to use
414 */
415struct GNUNET_PQ_ResultSpec 398struct GNUNET_PQ_ResultSpec
416GNUNET_PQ_result_spec_rsa_signature (const char *name, 399GNUNET_PQ_result_spec_rsa_signature (const char *name,
417 struct GNUNET_CRYPTO_RsaSignature **sig) 400 struct GNUNET_CRYPTO_RsaSignature **sig)
@@ -509,13 +492,6 @@ clean_string (void *cls,
509} 492}
510 493
511 494
512/**
513 * 0-terminated string expected.
514 *
515 * @param name name of the field in the table
516 * @param[out] dst where to store the result, allocated
517 * @return array entry for the result specification to use
518 */
519struct GNUNET_PQ_ResultSpec 495struct GNUNET_PQ_ResultSpec
520GNUNET_PQ_result_spec_string (const char *name, 496GNUNET_PQ_result_spec_string (const char *name,
521 char **dst) 497 char **dst)
@@ -595,13 +571,6 @@ extract_rel_time (void *cls,
595} 571}
596 572
597 573
598/**
599 * Relative time expected.
600 *
601 * @param name name of the field in the table
602 * @param[out] at where to store the result
603 * @return array entry for the result specification to use
604 */
605struct GNUNET_PQ_ResultSpec 574struct GNUNET_PQ_ResultSpec
606GNUNET_PQ_result_spec_relative_time (const char *name, 575GNUNET_PQ_result_spec_relative_time (const char *name,
607 struct GNUNET_TIME_Relative *rt) 576 struct GNUNET_TIME_Relative *rt)
@@ -685,13 +654,6 @@ extract_abs_time (void *cls,
685} 654}
686 655
687 656
688/**
689 * Absolute time expected.
690 *
691 * @param name name of the field in the table
692 * @param[out] at where to store the result
693 * @return array entry for the result specification to use
694 */
695struct GNUNET_PQ_ResultSpec 657struct GNUNET_PQ_ResultSpec
696GNUNET_PQ_result_spec_absolute_time (const char *name, 658GNUNET_PQ_result_spec_absolute_time (const char *name,
697 struct GNUNET_TIME_Absolute *at) 659 struct GNUNET_TIME_Absolute *at)
@@ -706,13 +668,6 @@ GNUNET_PQ_result_spec_absolute_time (const char *name,
706} 668}
707 669
708 670
709/**
710 * Absolute time in network byte order expected.
711 *
712 * @param name name of the field in the table
713 * @param[out] at where to store the result
714 * @return array entry for the result specification to use
715 */
716struct GNUNET_PQ_ResultSpec 671struct GNUNET_PQ_ResultSpec
717GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, 672GNUNET_PQ_result_spec_absolute_time_nbo (const char *name,
718 struct GNUNET_TIME_AbsoluteNBO *at) 673 struct GNUNET_TIME_AbsoluteNBO *at)
@@ -786,13 +741,6 @@ extract_uint16 (void *cls,
786} 741}
787 742
788 743
789/**
790 * uint16_t expected.
791 *
792 * @param name name of the field in the table
793 * @param[out] u16 where to store the result
794 * @return array entry for the result specification to use
795 */
796struct GNUNET_PQ_ResultSpec 744struct GNUNET_PQ_ResultSpec
797GNUNET_PQ_result_spec_uint16 (const char *name, 745GNUNET_PQ_result_spec_uint16 (const char *name,
798 uint16_t *u16) 746 uint16_t *u16)
@@ -869,13 +817,6 @@ extract_uint32 (void *cls,
869} 817}
870 818
871 819
872/**
873 * uint32_t expected.
874 *
875 * @param name name of the field in the table
876 * @param[out] u32 where to store the result
877 * @return array entry for the result specification to use
878 */
879struct GNUNET_PQ_ResultSpec 820struct GNUNET_PQ_ResultSpec
880GNUNET_PQ_result_spec_uint32 (const char *name, 821GNUNET_PQ_result_spec_uint32 (const char *name,
881 uint32_t *u32) 822 uint32_t *u32)
@@ -952,22 +893,16 @@ extract_uint64 (void *cls,
952} 893}
953 894
954 895
955/**
956 * uint64_t expected.
957 *
958 * @param name name of the field in the table
959 * @param[out] u64 where to store the result
960 * @return array entry for the result specification to use
961 */
962struct GNUNET_PQ_ResultSpec 896struct GNUNET_PQ_ResultSpec
963GNUNET_PQ_result_spec_uint64 (const char *name, 897GNUNET_PQ_result_spec_uint64 (const char *name,
964 uint64_t *u64) 898 uint64_t *u64)
965{ 899{
966 struct GNUNET_PQ_ResultSpec res = 900 struct GNUNET_PQ_ResultSpec res = {
967 { &extract_uint64, 901 &extract_uint64,
968 NULL, 902 NULL,
969 NULL, 903 NULL,
970 (void *) u64, sizeof(*u64), (name), NULL }; 904 (void *) u64, sizeof(*u64), (name), NULL
905 };
971 906
972 return res; 907 return res;
973} 908}