GNUnet 0.24.4-talerdev.1-26-g056a24676
 
Loading...
Searching...
No Matches
pq_query_helper.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2014, 2015, 2016, 2020, 2025 GNUnet e.V.
4
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
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "platform.h"
27#include "gnunet_common.h"
28#include "gnunet_pq_lib.h"
29#include "gnunet_time_lib.h"
30#include "pq.h"
31
46static int
47qconv_null (void *cls,
48 const void *data,
49 size_t data_len,
50 void *param_values[],
51 int param_lengths[],
52 int param_formats[],
53 unsigned int param_length,
54 void *scratch[],
55 unsigned int scratch_length)
56{
57 (void) scratch;
58 (void) scratch_length;
59 (void) data;
60 (void) data_len;
61 GNUNET_break (NULL == cls);
62 if (1 != param_length)
63 return -1;
64 param_values[0] = NULL;
65 param_lengths[0] = 0;
66 param_formats[0] = 1;
67 return 0;
68}
69
70
73{
74 struct GNUNET_PQ_QueryParam res = {
75 .conv = &qconv_null,
76 .num_params = 1
77 };
78
79 return res;
80}
81
82
97static int
98qconv_fixed (void *cls,
99 const void *data,
100 size_t data_len,
101 void *param_values[],
102 int param_lengths[],
103 int param_formats[],
104 unsigned int param_length,
105 void *scratch[],
106 unsigned int scratch_length)
107{
108 (void) scratch;
109 (void) scratch_length;
110 GNUNET_break (NULL == cls);
111 if (1 != param_length)
112 return -1;
113 param_values[0] = (void *) data;
114 param_lengths[0] = data_len;
115 param_formats[0] = 1;
116 return 0;
117}
118
119
122 size_t ptr_size)
123{
124 struct GNUNET_PQ_QueryParam res = {
125 .conv = &qconv_fixed,
126 .conv_cls = NULL,
127 .data = ptr,
128 .size = ptr_size,
129 .num_params = 1
130 };
131
132 return res;
133}
134
135
138{
140 strlen (ptr));
141}
142
143
146{
147 static uint8_t bt = 1;
148 static uint8_t bf = 0;
149
150 return GNUNET_PQ_query_param_fixed_size (b ? &bt : &bf,
151 sizeof (uint8_t));
152}
153
154
169static int
170qconv_uint16 (void *cls,
171 const void *data,
172 size_t data_len,
173 void *param_values[],
174 int param_lengths[],
175 int param_formats[],
176 unsigned int param_length,
177 void *scratch[],
178 unsigned int scratch_length)
179{
180 const uint16_t *u_hbo = data;
181 uint16_t *u_nbo;
182
183 (void) scratch;
184 (void) scratch_length;
185 GNUNET_break (NULL == cls);
186 if (1 != param_length)
187 return -1;
188 u_nbo = GNUNET_new (uint16_t);
189 scratch[0] = u_nbo;
190 *u_nbo = htons (*u_hbo);
191 param_values[0] = (void *) u_nbo;
192 param_lengths[0] = sizeof(uint16_t);
193 param_formats[0] = 1;
194 return 1;
195}
196
197
200{
201 struct GNUNET_PQ_QueryParam res = {
202 .conv = &qconv_uint16,
203 .data = x,
204 .size = sizeof(*x),
205 .num_params = 1
206 };
207
208 return res;
209}
210
211
226static int
227qconv_uint32 (void *cls,
228 const void *data,
229 size_t data_len,
230 void *param_values[],
231 int param_lengths[],
232 int param_formats[],
233 unsigned int param_length,
234 void *scratch[],
235 unsigned int scratch_length)
236{
237 const uint32_t *u_hbo = data;
238 uint32_t *u_nbo;
239
240 (void) scratch;
241 (void) scratch_length;
242 GNUNET_break (NULL == cls);
243 if (1 != param_length)
244 return -1;
245 u_nbo = GNUNET_new (uint32_t);
246 scratch[0] = u_nbo;
247 *u_nbo = htonl (*u_hbo);
248 param_values[0] = (void *) u_nbo;
249 param_lengths[0] = sizeof(uint32_t);
250 param_formats[0] = 1;
251 return 1;
252}
253
254
257{
258 struct GNUNET_PQ_QueryParam res = {
259 .conv = &qconv_uint32,
260 .data = x,
261 .size = sizeof(*x),
262 .num_params = 1
263 };
264
265 return res;
266}
267
268
283static int
284qconv_uint64 (void *cls,
285 const void *data,
286 size_t data_len,
287 void *param_values[],
288 int param_lengths[],
289 int param_formats[],
290 unsigned int param_length,
291 void *scratch[],
292 unsigned int scratch_length)
293{
294 const uint64_t *u_hbo = data;
295 uint64_t *u_nbo;
296
297 (void) scratch;
298 (void) scratch_length;
299 GNUNET_break (NULL == cls);
300 if (1 != param_length)
301 return -1;
302 u_nbo = GNUNET_new (uint64_t);
303 scratch[0] = u_nbo;
304 *u_nbo = GNUNET_htonll (*u_hbo);
305 param_values[0] = (void *) u_nbo;
306 param_lengths[0] = sizeof(uint64_t);
307 param_formats[0] = 1;
308 return 1;
309}
310
311
314{
315 struct GNUNET_PQ_QueryParam res = {
316 .conv = &qconv_uint64,
317 .data = x,
318 .size = sizeof(*x),
319 .num_params = 1
320 };
321
322 return res;
323}
324
325
340static int
341qconv_int16 (void *cls,
342 const void *data,
343 size_t data_len,
344 void *param_values[],
345 int param_lengths[],
346 int param_formats[],
347 unsigned int param_length,
348 void *scratch[],
349 unsigned int scratch_length)
350{
351 const int16_t *u_hbo = data;
352 int16_t *u_nbo;
353
354 (void) scratch;
355 (void) scratch_length;
356 GNUNET_break (NULL == cls);
357 if (1 != param_length)
358 return -1;
359 u_nbo = GNUNET_new (int16_t);
360 scratch[0] = u_nbo;
361 *u_nbo = GNUNET_htobe16 (*u_hbo);
362 param_values[0] = (void *) u_nbo;
363 param_lengths[0] = sizeof(int16_t);
364 param_formats[0] = 1;
365 return 1;
366}
367
368
371{
372 struct GNUNET_PQ_QueryParam res = {
373 .conv = &qconv_int16,
374 .data = x,
375 .size = sizeof(*x),
376 .num_params = 1
377 };
378
379 return res;
380}
381
382
397static int
398qconv_int64 (void *cls,
399 const void *data,
400 size_t data_len,
401 void *param_values[],
402 int param_lengths[],
403 int param_formats[],
404 unsigned int param_length,
405 void *scratch[],
406 unsigned int scratch_length)
407{
408 const int64_t *u_hbo = data;
409 int64_t *u_nbo;
410
411 (void) scratch;
412 (void) scratch_length;
413 GNUNET_break (NULL == cls);
414 if (1 != param_length)
415 return -1;
416 u_nbo = GNUNET_new (int64_t);
417 scratch[0] = u_nbo;
418 *u_nbo = GNUNET_htonll (*u_hbo);
419 param_values[0] = (void *) u_nbo;
420 param_lengths[0] = sizeof(int64_t);
421 param_formats[0] = 1;
422 return 1;
423}
424
425
428{
429 struct GNUNET_PQ_QueryParam res = {
430 .conv = &qconv_int64,
431 .data = x,
432 .size = sizeof(*x),
433 .num_params = 1
434 };
435
436 return res;
437}
438
439
454static int
456 const void *data,
457 size_t data_len,
458 void *param_values[],
459 int param_lengths[],
460 int param_formats[],
461 unsigned int param_length,
462 void *scratch[],
463 unsigned int scratch_length)
464{
465 const struct GNUNET_CRYPTO_RsaPublicKey *rsa = data;
466 void *buf;
467 size_t buf_size;
468
469 GNUNET_break (NULL == cls);
470 if (1 != param_length)
471 return -1;
473 &buf);
474 scratch[0] = buf;
475 param_values[0] = (void *) buf;
476 param_lengths[0] = buf_size;
477 param_formats[0] = 1;
478 return 1;
479}
480
481
484 const struct GNUNET_CRYPTO_RsaPublicKey *x)
485{
486 struct GNUNET_PQ_QueryParam res = {
488 .data = x,
489 .num_params = 1
490 };
491
492 return res;
493}
494
495
510static int
512 const void *data,
513 size_t data_len,
514 void *param_values[],
515 int param_lengths[],
516 int param_formats[],
517 unsigned int param_length,
518 void *scratch[],
519 unsigned int scratch_length)
520{
521 const struct GNUNET_CRYPTO_RsaSignature *sig = data;
522 void *buf;
523 size_t buf_size;
524
525 GNUNET_break (NULL == cls);
526 if (1 != param_length)
527 return -1;
529 &buf);
530 scratch[0] = buf;
531 param_values[0] = (void *) buf;
532 param_lengths[0] = buf_size;
533 param_formats[0] = 1;
534 return 1;
535}
536
537
540{
541 struct GNUNET_PQ_QueryParam res = {
543 .data = x,
544 .num_params = 1
545 };
546
547 return res;
548}
549
550
565static int
566qconv_rel_time (void *cls,
567 const void *data,
568 size_t data_len,
569 void *param_values[],
570 int param_lengths[],
571 int param_formats[],
572 unsigned int param_length,
573 void *scratch[],
574 unsigned int scratch_length)
575{
576 const struct GNUNET_TIME_Relative *u = data;
577 struct GNUNET_TIME_Relative rel;
578 uint64_t *u_nbo;
579
580 GNUNET_break (NULL == cls);
581 if (1 != param_length)
582 return -1;
583 rel = *u;
584 if (rel.rel_value_us > INT64_MAX)
585 rel.rel_value_us = INT64_MAX;
586 u_nbo = GNUNET_new (uint64_t);
587 scratch[0] = u_nbo;
588 *u_nbo = GNUNET_htonll (rel.rel_value_us);
589 param_values[0] = (void *) u_nbo;
590 param_lengths[0] = sizeof(uint64_t);
591 param_formats[0] = 1;
592 return 1;
593}
594
595
598{
599 struct GNUNET_PQ_QueryParam res = {
601 .data = x,
602 .size = sizeof(*x),
603 .num_params = 1
604 };
605
606 return res;
607}
608
609
624static int
625qconv_abs_time (void *cls,
626 const void *data,
627 size_t data_len,
628 void *param_values[],
629 int param_lengths[],
630 int param_formats[],
631 unsigned int param_length,
632 void *scratch[],
633 unsigned int scratch_length)
634{
635 const struct GNUNET_TIME_Absolute *u = data;
636 struct GNUNET_TIME_Absolute abs;
637 uint64_t *u_nbo;
638
639 GNUNET_break (NULL == cls);
640 if (1 != param_length)
641 return -1;
642 abs = *u;
643 if (abs.abs_value_us > INT64_MAX)
644 abs.abs_value_us = INT64_MAX;
645 u_nbo = GNUNET_new (uint64_t);
646 scratch[0] = u_nbo;
647 *u_nbo = GNUNET_htonll (abs.abs_value_us);
648 param_values[0] = (void *) u_nbo;
649 param_lengths[0] = sizeof(uint64_t);
650 param_formats[0] = 1;
651 return 1;
652}
653
654
657{
658 struct GNUNET_PQ_QueryParam res = {
660 .data = x,
661 .size = sizeof(*x),
662 .num_params = 1
663 };
664
665 return res;
666}
667
668
671 const struct GNUNET_TIME_AbsoluteNBO *x)
672{
673 return GNUNET_PQ_query_param_auto_from_type (&x->abs_value_us__);
674}
675
676
682
683
690
691
699{
706 const size_t *sizes;
707
712 size_t same_size;
713
720
725
729 Oid oid;
730};
731
736static void
738{
739 GNUNET_free (cls);
740}
741
742
761static int
763 void *cls,
764 const void *data,
765 size_t data_len,
766 void *param_values[],
767 int param_lengths[],
768 int param_formats[],
769 unsigned int param_length,
770 void *scratch[],
771 unsigned int scratch_length)
772{
773 struct qconv_array_cls *meta = cls;
774 size_t num = data_len;
775 size_t total_size;
776 const size_t *sizes;
777 bool same_sized;
778 size_t *string_lengths = NULL;
779 void *elements = NULL;
780 bool noerror = true;
781 bool has_nulls = false;
782 bool is_null[num];
783
784 (void) (param_length);
785 (void) (scratch_length);
786
787 GNUNET_assert (NULL != meta);
788 GNUNET_assert (num < INT_MAX);
789
790 sizes = meta->sizes;
791 same_sized = (0 != meta->same_size);
792 memset (is_null, 0, num);
793
794#define RETURN_UNLESS(cond) \
795 do { \
796 if (! (cond)) \
797 { \
798 GNUNET_break ((cond)); \
799 noerror = false; \
800 goto DONE; \
801 } \
802 } while (0)
803
804 /* Calculate sizes and check bounds */
805 {
806 /* num * length-field */
807 size_t x = sizeof(uint32_t);
808 size_t y = x * num;
809 RETURN_UNLESS ((0 == num) || (y / num == x));
810
811 /* size of header */
812 total_size = x = sizeof(struct pq_array_header);
813 total_size += y;
814 RETURN_UNLESS (total_size >= x);
815
816 /* sizes of elements */
817 if (same_sized)
818 {
819 if (meta->continuous)
820 {
821 x = num * meta->same_size;
822 RETURN_UNLESS ((0 == num) || (x / num == meta->same_size));
823
824 y = total_size;
825 total_size += x;
826 RETURN_UNLESS (total_size >= y);
827 }
828 else
829 {
830 /* Not continuous, but same sized.
831 * There might be NULL pointers in the array, though. */
832 for (unsigned int i = 0; i < num; i++)
833 {
834 const void **ptr = (const void **) data;
835
836 if (NULL != ptr[i])
837 {
838 total_size += meta->same_size;
839 RETURN_UNLESS (total_size >= meta->same_size);
840 }
841 else
842 {
843 has_nulls = true;
844 is_null[i] = true;
845 }
846 }
847 }
848 }
849 else /* sizes are different per element, provided in sizes[] */
850 {
851 /* For an array of strings we need to get their length's first */
852 if (array_of_string == meta->typ)
853 {
854 string_lengths = GNUNET_new_array (num, size_t);
855
856 if (meta->continuous)
857 {
858 const char *ptr = data;
859
860 for (unsigned int i = 0; i < num; i++)
861 {
862 size_t len = strlen (ptr);
863 RETURN_UNLESS (len < INT_MAX);
864 string_lengths[i] = len;
865 ptr += len + 1;
866 }
867 }
868 else
869 {
870 const char **str = (const char **) data;
871
872 for (unsigned int i = 0; i < num; i++)
873 {
874 if (NULL != str[i])
875 {
876 size_t len = strlen (str[i]);
877 RETURN_UNLESS (len < INT_MAX);
878 string_lengths[i] = len;
879 }
880 else
881 {
882 has_nulls = true;
883 string_lengths[i] = 0;
884 is_null[i] = true;
885 }
886 }
887 }
888 sizes = string_lengths;
889 }
890 else
891 {
892 /* Ensure consistency between NULL elements and sizes */
893 for (unsigned int i = 0; i < num; i++)
894 {
895 const char **ptr = (const char **) data;
896
897 if (NULL == ptr[i])
898 {
899 RETURN_UNLESS (sizes[i] == 0);
900 has_nulls = true;
901 is_null[i] = true;
902 }
903 else
904 RETURN_UNLESS (sizes[i] < INT_MAX);
905 }
906 }
907
908 for (unsigned int i = 0; i < num; i++)
909 {
910 x = total_size;
911 total_size += sizes[i];
912 RETURN_UNLESS (total_size >= x);
913 }
914 }
915
916 RETURN_UNLESS (total_size < INT_MAX);
917 elements = GNUNET_malloc (total_size);
918 }
919
920 /* Write data */
921 {
922 char *in = (char *) data;
923 char *out = elements;
924 struct pq_array_header h = {
925 .ndim = htonl (1), /* We only support one-dimensional arrays */
926 .has_nulls = has_nulls ? htonl (1) : 0,
927 .lbound = htonl (1), /* Default start index value */
928 .dim = htonl (num),
929 .oid = htonl (meta->oid),
930 };
931
932 /* Write header */
933 GNUNET_memcpy (out, &h, sizeof(h));
934 out += sizeof(h);
935
936
937 /* Write elements */
938 for (unsigned int i = 0; i < num; i++)
939 {
940 size_t sz = same_sized ? meta->same_size : sizes[i];
941 uint32_t hsz = is_null[i] ? htonl (-1) : htonl (sz);
942
943 GNUNET_memcpy (out,
944 &hsz,
945 sizeof(hsz));
946 out += sizeof(uint32_t);
947
948 switch (meta->typ)
949 {
950 case array_of_bool:
951 {
952 GNUNET_assert (sizeof(bool) == sz);
953 *(bool *) out = (*(bool *) in);
954 in += sz;
955 break;
956 }
957 case array_of_uint16:
958 {
959 GNUNET_assert (sizeof(uint16_t) == sz);
960 *(uint16_t *) out = htons (*(uint16_t *) in);
961 in += sz;
962 break;
963 }
964 case array_of_uint32:
965 {
966 uint32_t v;
967 GNUNET_assert (sizeof(uint32_t) == sz);
968
969 v = htonl (*(uint32_t *) in);
970 GNUNET_memcpy (out,
971 &v,
972 sizeof(v));
973 in += sz;
974 break;
975 }
976 case array_of_uint64:
977 {
978 uint64_t tmp;
979 GNUNET_assert (sizeof(uint64_t) == sz);
980
981 tmp = GNUNET_htonll (*(uint64_t *) in);
982 GNUNET_memcpy (out,
983 &tmp,
984 sizeof(tmp));
985 in += sz;
986 break;
987 }
988 case array_of_byte:
989 case array_of_string:
990 if (! is_null[i])
991 {
992 const void *ptr;
993
994 if (meta->continuous)
995 {
996 size_t nullbyte = (array_of_string == meta->typ) ? 1 : 0;
997
998 ptr = in;
999 in += sz + nullbyte;
1000 }
1001 else
1002 ptr = ((const char **) data)[i];
1003
1004 RETURN_UNLESS (NULL != ptr);
1005 GNUNET_memcpy (out,
1006 ptr,
1007 sz);
1008 }
1009 break;
1010 case array_of_abs_time:
1011 case array_of_rel_time:
1012 case array_of_timestamp:
1013 if (! is_null [i])
1014 {
1015 uint64_t val;
1016
1017 switch (meta->typ)
1018 {
1019 case array_of_abs_time:
1020 {
1021 const struct GNUNET_TIME_Absolute *abs =
1022 (const struct GNUNET_TIME_Absolute *) in;
1023
1024 GNUNET_assert (sizeof(struct GNUNET_TIME_Absolute) == sz);
1025
1026 if (! meta->continuous)
1027 abs = ((const struct GNUNET_TIME_Absolute **) data)[i];
1028
1029 RETURN_UNLESS (NULL != abs);
1030 val = abs->abs_value_us;
1031 break;
1032 }
1033 case array_of_rel_time:
1034 {
1035 const struct GNUNET_TIME_Relative *rel =
1036 (const struct GNUNET_TIME_Relative *) in;
1037
1038 GNUNET_assert (sizeof(struct GNUNET_TIME_Relative) == sz);
1039
1040 if (! meta->continuous)
1041 rel = ((const struct GNUNET_TIME_Relative **) data)[i];
1042
1043 RETURN_UNLESS (NULL != rel);
1044 val = rel->rel_value_us;
1045 break;
1046 }
1047 case array_of_timestamp:
1048 {
1049 const struct GNUNET_TIME_Timestamp *ts =
1050 (const struct GNUNET_TIME_Timestamp *) in;
1051
1052 GNUNET_assert (sizeof(struct GNUNET_TIME_Timestamp) == sz);
1053
1054 if (! meta->continuous)
1055 ts = ((const struct GNUNET_TIME_Timestamp **) data)[i];
1056
1057 RETURN_UNLESS (NULL != ts);
1058 val = ts->abs_time.abs_value_us;
1059 break;
1060 }
1061 default:
1062 {
1063 GNUNET_assert (0);
1064 }
1065 }
1066
1067 val = val > INT64_MAX ? INT64_MAX : val;
1068 val = GNUNET_htonll (val);
1069 GNUNET_memcpy (out,
1070 &val,
1071 sizeof(val));
1072
1073 if (meta->continuous)
1074 in += sz;
1075 }
1076 break;
1077 default:
1078 GNUNET_assert (0);
1079 break;
1080 }
1081
1082 if (! is_null[i])
1083 out += sz;
1084 }
1085 }
1086
1087 param_values[0] = elements;
1088 param_lengths[0] = total_size;
1089 param_formats[0] = 1;
1090 scratch[0] = elements;
1091
1092DONE:
1093 GNUNET_free (string_lengths);
1094
1095 if (noerror)
1096 return 1;
1097
1098 return -1;
1099}
1100
1101
1114static struct GNUNET_PQ_QueryParam
1116 unsigned int num,
1117 bool continuous,
1118 const void *elements,
1119 const size_t *sizes,
1120 size_t same_size,
1121 enum array_types typ,
1122 Oid oid)
1123{
1125
1126 meta->typ = typ;
1127 meta->oid = oid;
1128 meta->sizes = sizes;
1129 meta->same_size = same_size;
1130 meta->continuous = continuous;
1131
1132 {
1133 struct GNUNET_PQ_QueryParam res = {
1134 .conv = qconv_array,
1135 .conv_cls = meta,
1136 .conv_cls_cleanup = &qconv_array_cls_cleanup,
1137 .data = elements,
1138 .size = num,
1139 .num_params = 1,
1140 };
1141
1142 return res;
1143 }
1144}
1145
1146
1149 unsigned int num,
1150 const bool *elements,
1151 struct GNUNET_PQ_Context *db)
1152{
1153 Oid oid;
1154
1157 "bool",
1158 &oid));
1160 true,
1161 elements,
1162 NULL,
1163 sizeof(bool),
1165 oid);
1166}
1167
1168
1171 unsigned int num,
1172 const uint16_t *elements,
1173 struct GNUNET_PQ_Context *db)
1174{
1175 Oid oid;
1176
1179 "int2",
1180 &oid));
1182 true,
1183 elements,
1184 NULL,
1185 sizeof(uint16_t),
1187 oid);
1188}
1189
1190
1193 unsigned int num,
1194 const uint32_t *elements,
1195 struct GNUNET_PQ_Context *db)
1196{
1197 Oid oid;
1198
1201 "int4",
1202 &oid));
1204 true,
1205 elements,
1206 NULL,
1207 sizeof(uint32_t),
1209 oid);
1210}
1211
1212
1215 unsigned int num,
1216 const uint64_t *elements,
1217 struct GNUNET_PQ_Context *db)
1218{
1219 Oid oid;
1220
1223 "int8",
1224 &oid));
1226 true,
1227 elements,
1228 NULL,
1229 sizeof(uint64_t),
1231 oid);
1232}
1233
1234
1237 unsigned int num,
1238 const void *elements,
1239 const size_t *sizes,
1240 struct GNUNET_PQ_Context *db)
1241{
1242 Oid oid;
1243
1246 "bytea",
1247 &oid));
1249 true,
1250 elements,
1251 sizes,
1252 0,
1254 oid);
1255}
1256
1257
1260 unsigned int num,
1261 const void *elements[static num],
1262 const size_t *sizes,
1263 struct GNUNET_PQ_Context *db)
1264{
1265 Oid oid;
1266
1269 "bytea",
1270 &oid));
1272 false,
1273 elements,
1274 sizes,
1275 0,
1277 oid);
1278}
1279
1280
1283 unsigned int num,
1284 const void *elements,
1285 size_t same_size,
1286 struct GNUNET_PQ_Context *db)
1287{
1288 Oid oid;
1289
1292 "bytea",
1293 &oid));
1295 true,
1296 elements,
1297 NULL,
1298 same_size,
1300 oid);
1301}
1302
1303
1306 unsigned int num,
1307 const void *elements[static num],
1308 size_t same_size,
1309 struct GNUNET_PQ_Context *db)
1310{
1311 Oid oid;
1312
1315 "bytea",
1316 &oid));
1318 false,
1319 elements,
1320 NULL,
1321 same_size,
1323 oid);
1324}
1325
1326
1329 unsigned int num,
1330 const char *elements,
1331 struct GNUNET_PQ_Context *db)
1332{
1333 Oid oid;
1334
1337 "text",
1338 &oid));
1340 true,
1341 elements,
1342 NULL,
1343 0,
1345 oid);
1346}
1347
1348
1351 unsigned int num,
1352 const char *elements[static num],
1353 struct GNUNET_PQ_Context *db)
1354{
1355 Oid oid;
1356
1359 "text",
1360 &oid));
1362 false,
1363 elements,
1364 NULL,
1365 0,
1367 oid);
1368}
1369
1370
1373 unsigned int num,
1374 const struct GNUNET_TIME_Absolute *elements,
1375 struct GNUNET_PQ_Context *db)
1376{
1377 Oid oid;
1378
1381 "int8",
1382 &oid));
1384 true,
1385 elements,
1386 NULL,
1387 sizeof(struct GNUNET_TIME_Absolute),
1389 oid);
1390}
1391
1392
1395 unsigned int num,
1396 const struct GNUNET_TIME_Absolute *elements[],
1397 struct GNUNET_PQ_Context *db)
1398{
1399 Oid oid;
1400
1403 "int8",
1404 &oid));
1406 false,
1407 elements,
1408 NULL,
1409 sizeof(struct GNUNET_TIME_Absolute),
1411 oid);
1412}
1413
1414
1417 unsigned int num,
1418 const struct GNUNET_TIME_Relative *elements,
1419 struct GNUNET_PQ_Context *db)
1420{
1421 Oid oid;
1422
1425 "int8",
1426 &oid));
1428 true,
1429 elements,
1430 NULL,
1431 sizeof(struct GNUNET_TIME_Relative),
1433 oid);
1434}
1435
1436
1439 unsigned int num,
1440 const struct GNUNET_TIME_Relative *elements[],
1441 struct GNUNET_PQ_Context *db)
1442{
1443 Oid oid;
1444
1447 "int8",
1448 &oid));
1450 false,
1451 elements,
1452 NULL,
1453 sizeof(struct GNUNET_TIME_Relative),
1455 oid);
1456}
1457
1458
1461 unsigned int num,
1462 const struct GNUNET_TIME_Timestamp *elements,
1463 struct GNUNET_PQ_Context *db)
1464{
1465 Oid oid;
1466
1469 "int8",
1470 &oid));
1472 true,
1473 elements,
1474 NULL,
1475 sizeof(struct GNUNET_TIME_Timestamp),
1477 oid);
1478}
1479
1480
1483 unsigned int num,
1484 const struct GNUNET_TIME_Timestamp *elements[],
1485 struct GNUNET_PQ_Context *db)
1486{
1487 Oid oid;
1488
1491 "int8",
1492 &oid));
1494 false,
1495 elements,
1496 NULL,
1497 sizeof(struct GNUNET_TIME_Timestamp),
1499 oid);
1500}
1501
1502
1517static int
1519 const void *data,
1520 size_t data_len,
1521 void *param_values[],
1522 int param_lengths[],
1523 int param_formats[],
1524 unsigned int param_length,
1525 void *scratch[],
1526 unsigned int scratch_length)
1527{
1528 const struct GNUNET_CRYPTO_BlindSignPublicKey *public_key = data;
1529 size_t tlen;
1530 size_t len;
1531 uint32_t be;
1532 char *buf;
1533 void *tbuf;
1534
1535 (void) cls;
1536 (void) data_len;
1537 GNUNET_assert (1 == param_length);
1538 GNUNET_assert (scratch_length > 0);
1539 GNUNET_break (NULL == cls);
1540 be = htonl ((uint32_t) public_key->cipher);
1541 switch (public_key->cipher)
1542 {
1545 public_key->details.rsa_public_key,
1546 &tbuf);
1547 break;
1549 tlen = sizeof (public_key->details.cs_public_key);
1550 break;
1551 default:
1552 GNUNET_assert (0);
1553 }
1554 len = tlen + sizeof (be);
1555 buf = GNUNET_malloc (len);
1556 GNUNET_memcpy (buf,
1557 &be,
1558 sizeof (be));
1559 switch (public_key->cipher)
1560 {
1562 GNUNET_memcpy (&buf[sizeof (be)],
1563 tbuf,
1564 tlen);
1565 GNUNET_free (tbuf);
1566 break;
1568 GNUNET_memcpy (&buf[sizeof (be)],
1569 &public_key->details.cs_public_key,
1570 tlen);
1571 break;
1572 default:
1573 GNUNET_assert (0);
1574 }
1575
1576 scratch[0] = buf;
1577 param_values[0] = (void *) buf;
1578 param_lengths[0] = len;
1579 param_formats[0] = 1;
1580 return 1;
1581}
1582
1583
1592{
1593 struct GNUNET_PQ_QueryParam res = {
1595 .data = pub,
1596 .num_params = 1
1597 };
1598
1599 return res;
1600}
1601
1602
1617static int
1619 const void *data,
1620 size_t data_len,
1621 void *param_values[],
1622 int param_lengths[],
1623 int param_formats[],
1624 unsigned int param_length,
1625 void *scratch[],
1626 unsigned int scratch_length)
1627{
1628 const struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key = data;
1629 size_t tlen;
1630 size_t len;
1631 uint32_t be;
1632 char *buf;
1633 void *tbuf;
1634
1635 (void) cls;
1636 (void) data_len;
1637 GNUNET_assert (1 == param_length);
1638 GNUNET_assert (scratch_length > 0);
1639 GNUNET_break (NULL == cls);
1640 be = htonl ((uint32_t) private_key->cipher);
1641 switch (private_key->cipher)
1642 {
1645 private_key->details.rsa_private_key,
1646 &tbuf);
1647 break;
1649 tlen = sizeof (private_key->details.cs_private_key);
1650 break;
1651 default:
1652 GNUNET_assert (0);
1653 }
1654 len = tlen + sizeof (be);
1655 buf = GNUNET_malloc (len);
1656 GNUNET_memcpy (buf,
1657 &be,
1658 sizeof (be));
1659 switch (private_key->cipher)
1660 {
1662 GNUNET_memcpy (&buf[sizeof (be)],
1663 tbuf,
1664 tlen);
1665 GNUNET_free (tbuf);
1666 break;
1668 GNUNET_memcpy (&buf[sizeof (be)],
1669 &private_key->details.cs_private_key,
1670 tlen);
1671 break;
1672 default:
1673 GNUNET_assert (0);
1674 }
1675
1676 scratch[0] = buf;
1677 param_values[0] = (void *) buf;
1678 param_lengths[0] = len;
1679 param_formats[0] = 1;
1680 return 1;
1681}
1682
1683
1691 const struct GNUNET_CRYPTO_BlindSignPrivateKey *priv)
1692{
1693 struct GNUNET_PQ_QueryParam res = {
1695 .data = priv,
1696 .num_params = 1
1697 };
1698
1699 return res;
1700}
1701
1702
1717static int
1719 const void *data,
1720 size_t data_len,
1721 void *param_values[],
1722 int param_lengths[],
1723 int param_formats[],
1724 unsigned int param_length,
1725 void *scratch[],
1726 unsigned int scratch_length)
1727{
1728 const struct GNUNET_CRYPTO_UnblindedSignature *ubs = data;
1729 size_t tlen;
1730 size_t len;
1731 uint32_t be[2];
1732 char *buf;
1733 void *tbuf;
1734
1735 (void) cls;
1736 (void) data_len;
1737 GNUNET_assert (1 == param_length);
1738 GNUNET_assert (scratch_length > 0);
1739 GNUNET_break (NULL == cls);
1740 be[0] = htonl ((uint32_t) ubs->cipher);
1741 be[1] = htonl (0x00); /* magic marker: unblinded */
1742 switch (ubs->cipher)
1743 {
1747 &tbuf);
1748 break;
1750 tlen = sizeof (ubs->details.cs_signature);
1751 break;
1752 default:
1753 GNUNET_assert (0);
1754 }
1755 len = tlen + sizeof (be);
1756 buf = GNUNET_malloc (len);
1757 GNUNET_memcpy (buf,
1758 &be,
1759 sizeof (be));
1760 switch (ubs->cipher)
1761 {
1763 GNUNET_memcpy (&buf[sizeof (be)],
1764 tbuf,
1765 tlen);
1766 GNUNET_free (tbuf);
1767 break;
1769 GNUNET_memcpy (&buf[sizeof (be)],
1770 &ubs->details.cs_signature,
1771 tlen);
1772 break;
1773 default:
1774 GNUNET_assert (0);
1775 }
1776
1777 scratch[0] = buf;
1778 param_values[0] = (void *) buf;
1779 param_lengths[0] = len;
1780 param_formats[0] = 1;
1781 return 1;
1782}
1783
1784
1792 const struct GNUNET_CRYPTO_UnblindedSignature *sig)
1793{
1794 struct GNUNET_PQ_QueryParam res = {
1796 .data = sig,
1797 .num_params = 1
1798 };
1799
1800 return res;
1801}
1802
1803
1818static int
1820 const void *data,
1821 size_t data_len,
1822 void *param_values[],
1823 int param_lengths[],
1824 int param_formats[],
1825 unsigned int param_length,
1826 void *scratch[],
1827 unsigned int scratch_length)
1828{
1829 const struct GNUNET_CRYPTO_BlindedSignature *bs = data;
1830 size_t tlen;
1831 size_t len;
1832 uint32_t be[2];
1833 char *buf;
1834 void *tbuf;
1835
1836 (void) cls;
1837 (void) data_len;
1838 GNUNET_assert (1 == param_length);
1839 GNUNET_assert (scratch_length > 0);
1840 GNUNET_break (NULL == cls);
1841 be[0] = htonl ((uint32_t) bs->cipher);
1842 be[1] = htonl (0x01); /* magic marker: blinded */
1843 switch (bs->cipher)
1844 {
1848 &tbuf);
1849 break;
1851 tlen = sizeof (bs->details.blinded_cs_answer);
1852 break;
1853 default:
1854 GNUNET_assert (0);
1855 }
1856 len = tlen + sizeof (be);
1857 buf = GNUNET_malloc (len);
1858 GNUNET_memcpy (buf,
1859 &be,
1860 sizeof (be));
1861 switch (bs->cipher)
1862 {
1864 GNUNET_memcpy (&buf[sizeof (be)],
1865 tbuf,
1866 tlen);
1867 GNUNET_free (tbuf);
1868 break;
1870 GNUNET_memcpy (&buf[sizeof (be)],
1872 tlen);
1873 break;
1874 default:
1875 GNUNET_assert (0);
1876 }
1877
1878 scratch[0] = buf;
1879 param_values[0] = (void *) buf;
1880 param_lengths[0] = len;
1881 param_formats[0] = 1;
1882 return 1;
1883}
1884
1885
1893 const struct GNUNET_CRYPTO_BlindedSignature *b_sig)
1894{
1895 struct GNUNET_PQ_QueryParam res = {
1897 .data = b_sig,
1898 .num_params = 1
1899 };
1900
1901 return res;
1902}
1903
1904
1905/* end of pq_query_helper.c */
#define INT_MAX
static mp_limb_t u[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static char * data
The data to insert into the dht.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_FS_DirectoryBuilder * db
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
helper functions for Postgres DB interactions
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size(const void *ptr, size_t ptr_size)
Generate query parameter for a buffer ptr of ptr_size bytes.
#define GNUNET_PQ_query_param_auto_from_type(x)
Generate fixed-size query parameter with size determined by variable type.
uint32_t oid
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.
Definition pq_connect.c:461
Functions related to time.
size_t GNUNET_CRYPTO_rsa_public_key_encode(const struct GNUNET_CRYPTO_RsaPublicKey *key, void **buffer)
Encode the public key in a format suitable for storing it into a file.
Definition crypto_rsa.c:325
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
#define GNUNET_htobe16(x)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition crypto_rsa.c:181
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
@ GNUNET_OK
#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.
#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.
shared internal data structures of libgnunetpq
uint32_t has_nulls
Definition pq.h:1
array_types
Internal types that are supported as array types.
Definition pq.h:148
@ array_of_byte
Definition pq.h:153
@ array_of_uint32
Definition pq.h:151
@ array_of_string
Definition pq.h:154
@ array_of_rel_time
Definition pq.h:156
@ array_of_uint16
Definition pq.h:150
@ array_of_uint64
Definition pq.h:152
@ array_of_abs_time
Definition pq.h:155
@ array_of_timestamp
Definition pq.h:157
@ array_of_bool
Definition pq.h:149
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size(const void *ptr, size_t ptr_size)
Generate query parameter for a buffer ptr of ptr_size bytes.
static int qconv_fixed(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_rel_time(unsigned int num, const struct GNUNET_TIME_Relative *elements[], struct GNUNET_PQ_Context *db)
Generate query parameter for an array of relative time stamps (pointers)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint64(const uint64_t *x)
Generate query parameter for an uint64_t in host byte order.
static int qconv_rel_time(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_abs_time(unsigned int num, const struct GNUNET_TIME_Absolute *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of absolute time stamps (continuous)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_null(void)
Generate query parameter to create a NULL value.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_timestamp(unsigned int num, const struct GNUNET_TIME_Timestamp *elements[], struct GNUNET_PQ_Context *db)
Generate query parameter for an array of time stamps (pointers)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_pub(const struct GNUNET_CRYPTO_BlindSignPublicKey *pub)
Generate query parameter for a blind sign public key of variable size.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_abs_time(unsigned int num, const struct GNUNET_TIME_Absolute *elements[], struct GNUNET_PQ_Context *db)
Generate query parameter for an array of absolute time stamps (pointers)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint32(unsigned int num, const uint32_t *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of uint32_t in host byte order.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_unblinded_sig(const struct GNUNET_CRYPTO_UnblindedSignature *sig)
Generate query parameter for an unblinded signature of variable size.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes(unsigned int num, const void *elements[static num], const size_t *sizes, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of buffers elements, with sizes sizes.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x)
Generate query parameter for an absolute time value.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_relative_time(const struct GNUNET_TIME_Relative *x)
Generate query parameter for a relative time value.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint64(unsigned int num, const uint64_t *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of uint64 in host byte order.
#define RETURN_UNLESS(cond)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_int64(const int64_t *x)
Generate query parameter for an int64_t in host byte order.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint16(const uint16_t *x)
Generate query parameter for an uint16_t in host byte order.
static int qconv_unblinded_sig(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x)
Generate query parameter for an RSA public key.
static int qconv_blinded_sig(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_null(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_blind_sign_pub(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bool(unsigned int num, const bool *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of bool in host byte order.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x)
Generate query parameter for an absolute time value.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_string(unsigned int num, const char *elements[static num], struct GNUNET_PQ_Context *db)
Generate query parameter for an array of strings (pointers)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes(unsigned int num, const void *elements, const size_t *sizes, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of buffers elements, each of corresponding size given in sizes.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_bool(bool b)
Pass a boolean into a query.
static void qconv_array_cls_cleanup(void *cls)
Callback to cleanup a qconv_array_cls to be used during GNUNET_PQ_cleanup_query_params_closures.
static int qconv_uint64(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_blind_sign_priv(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_uint32(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_int16(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static int qconv_array(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters for arrays.
static int qconv_abs_time(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_priv(const struct GNUNET_CRYPTO_BlindSignPrivateKey *priv)
Generate query parameter for a blind sign private key of variable size.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blinded_sig(const struct GNUNET_CRYPTO_BlindedSignature *b_sig)
Generate query parameter for a blinded signature of variable size.
static int qconv_rsa_signature(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_timestamp(unsigned int num, const struct GNUNET_TIME_Timestamp *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of time stamps (continuous)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_rel_time(unsigned int num, const struct GNUNET_TIME_Relative *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of relative time stamps (continuous)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint16(unsigned int num, const uint16_t *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of uint16_t in host byte order.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint32(const uint32_t *x)
Generate query parameter for an uint32_t in host byte order.
static int qconv_uint16(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp(const struct GNUNET_TIME_Timestamp *x)
Generate query parameter for a timestamp.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_int16(const int16_t *x)
Generate query parameter for an int16_t in host byte order.
static int qconv_rsa_public_key(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp_nbo(const struct GNUNET_TIME_TimestampNBO *x)
Generate query parameter for a timestamp in NBO.
static int qconv_int64(void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length)
Function called to convert input argument into SQL parameters.
static struct GNUNET_PQ_QueryParam query_param_array_generic(unsigned int num, bool continuous, const void *elements, const size_t *sizes, size_t same_size, enum array_types typ, Oid oid)
Function to generate a typ specific query parameter and corresponding closure.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes_same_size(unsigned int num, const void *elements[static num], size_t same_size, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of pointers to buffers elements, each of the same size size.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_string(unsigned int num, const char *elements, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of strings (continuous)
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_string(const char *ptr)
Generate query parameter for a string.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes_same_size(unsigned int num, const void *elements, size_t same_size, struct GNUNET_PQ_Context *db)
Generate query parameter for an array of buffers elements, each of the same size size.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x)
Generate query parameter for an RSA signature.
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
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.
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.
Type for blinded signatures.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedSignature::@15 details
Details, depending on cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
The public information of an RSA key pair.
Definition crypto_rsa.c:53
Type of (unblinded) signatures.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
union GNUNET_CRYPTO_UnblindedSignature::@14 details
Details, depending on cipher.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Handle to Postgres database.
Definition pq.h:36
unsigned int num
Definition pq.h:128
Description of a DB query parameter.
GNUNET_PQ_QueryConverter conv
Function for how to handle this type of entry.
size_t size
Size of data.
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.
The header for a postgresql array in binary format.
Definition pq.h:167
Closure for the array type handlers.
const size_t * sizes
If not null, contains the array of sizes (the size of the array is the .size field in the ambient GNU...
enum array_types typ
Type of the array elements.
size_t same_size
If size and c_sizes are NULL, this field defines the same size for each element in the array.
Oid oid
Oid of the array elements.
bool continuous
If true, the array parameter to the data pointer to the qconv_array is a continuous byte array of dat...