diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-09 14:18:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-09 14:18:10 +0200 |
commit | f531d06a9d64d627034c2220769c1af63fb72297 (patch) | |
tree | 25eb2a39209beff39406e0fd5ca869df62fefa06 /src/include/gnunet_pq_lib.h | |
parent | 839139eb858c01bbba6a25062e32916f2689e252 (diff) | |
download | gnunet-f531d06a9d64d627034c2220769c1af63fb72297.tar.gz gnunet-f531d06a9d64d627034c2220769c1af63fb72297.zip |
fix gnunet-bugreport output issues
Diffstat (limited to 'src/include/gnunet_pq_lib.h')
-rw-r--r-- | src/include/gnunet_pq_lib.h | 142 |
1 files changed, 72 insertions, 70 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 492491e94..1734fb94d 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -46,16 +46,15 @@ | |||
46 | * @param scratch_length number of entries left in @a scratch | 46 | * @param scratch_length number of entries left in @a scratch |
47 | * @return -1 on error, number of offsets used in @a scratch otherwise | 47 | * @return -1 on error, number of offsets used in @a scratch otherwise |
48 | */ | 48 | */ |
49 | typedef int | 49 | typedef int (*GNUNET_PQ_QueryConverter) (void *cls, |
50 | (*GNUNET_PQ_QueryConverter)(void *cls, | 50 | const void *data, |
51 | const void *data, | 51 | size_t data_len, |
52 | size_t data_len, | 52 | void *param_values[], |
53 | void *param_values[], | 53 | int param_lengths[], |
54 | int param_lengths[], | 54 | int param_formats[], |
55 | int param_formats[], | 55 | unsigned int param_length, |
56 | unsigned int param_length, | 56 | void *scratch[], |
57 | void *scratch[], | 57 | unsigned int scratch_length); |
58 | unsigned int scratch_length); | ||
59 | 58 | ||
60 | 59 | ||
61 | /** | 60 | /** |
@@ -94,7 +93,10 @@ struct GNUNET_PQ_QueryParam | |||
94 | /** | 93 | /** |
95 | * End of query parameter specification. | 94 | * End of query parameter specification. |
96 | */ | 95 | */ |
97 | #define GNUNET_PQ_query_param_end { NULL, NULL, NULL, 0, 0 } | 96 | #define GNUNET_PQ_query_param_end \ |
97 | { \ | ||
98 | NULL, NULL, NULL, 0, 0 \ | ||
99 | } | ||
98 | 100 | ||
99 | 101 | ||
100 | /** | 102 | /** |
@@ -105,9 +107,7 @@ struct GNUNET_PQ_QueryParam | |||
105 | * @oaran ptr_size number of bytes in @a ptr | 107 | * @oaran ptr_size number of bytes in @a ptr |
106 | */ | 108 | */ |
107 | struct GNUNET_PQ_QueryParam | 109 | struct GNUNET_PQ_QueryParam |
108 | GNUNET_PQ_query_param_fixed_size (const void *ptr, | 110 | GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size); |
109 | size_t ptr_size); | ||
110 | |||
111 | 111 | ||
112 | 112 | ||
113 | /** | 113 | /** |
@@ -125,7 +125,8 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
125 | * | 125 | * |
126 | * @param x pointer to the query parameter to pass. | 126 | * @param x pointer to the query parameter to pass. |
127 | */ | 127 | */ |
128 | #define GNUNET_PQ_query_param_auto_from_type(x) GNUNET_PQ_query_param_fixed_size ((x), sizeof (*(x))) | 128 | #define GNUNET_PQ_query_param_auto_from_type(x) \ |
129 | GNUNET_PQ_query_param_fixed_size ((x), sizeof (*(x))) | ||
129 | 130 | ||
130 | 131 | ||
131 | /** | 132 | /** |
@@ -135,7 +136,8 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
135 | * @param x the query parameter to pass. | 136 | * @param x the query parameter to pass. |
136 | */ | 137 | */ |
137 | struct GNUNET_PQ_QueryParam | 138 | struct GNUNET_PQ_QueryParam |
138 | GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x); | 139 | GNUNET_PQ_query_param_rsa_public_key ( |
140 | const struct GNUNET_CRYPTO_RsaPublicKey *x); | ||
139 | 141 | ||
140 | 142 | ||
141 | /** | 143 | /** |
@@ -145,7 +147,8 @@ GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x | |||
145 | * @param x the query parameter to pass | 147 | * @param x the query parameter to pass |
146 | */ | 148 | */ |
147 | struct GNUNET_PQ_QueryParam | 149 | struct GNUNET_PQ_QueryParam |
148 | GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x); | 150 | GNUNET_PQ_query_param_rsa_signature ( |
151 | const struct GNUNET_CRYPTO_RsaSignature *x); | ||
149 | 152 | ||
150 | 153 | ||
151 | /** | 154 | /** |
@@ -165,7 +168,8 @@ GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | |||
165 | * @param x pointer to the query parameter to pass | 168 | * @param x pointer to the query parameter to pass |
166 | */ | 169 | */ |
167 | struct GNUNET_PQ_QueryParam | 170 | struct GNUNET_PQ_QueryParam |
168 | GNUNET_PQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x); | 171 | GNUNET_PQ_query_param_absolute_time_nbo ( |
172 | const struct GNUNET_TIME_AbsoluteNBO *x); | ||
169 | 173 | ||
170 | 174 | ||
171 | /** | 175 | /** |
@@ -211,13 +215,12 @@ GNUNET_PQ_query_param_uint64 (const uint64_t *x); | |||
211 | * #GNUNET_YES if all results could be extracted | 215 | * #GNUNET_YES if all results could be extracted |
212 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 216 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
213 | */ | 217 | */ |
214 | typedef int | 218 | typedef int (*GNUNET_PQ_ResultConverter) (void *cls, |
215 | (*GNUNET_PQ_ResultConverter)(void *cls, | 219 | PGresult *result, |
216 | PGresult *result, | 220 | int row, |
217 | int row, | 221 | const char *fname, |
218 | const char *fname, | 222 | size_t *dst_size, |
219 | size_t *dst_size, | 223 | void *dst); |
220 | void *dst); | ||
221 | 224 | ||
222 | 225 | ||
223 | /** | 226 | /** |
@@ -227,9 +230,7 @@ typedef int | |||
227 | * @param cls closure | 230 | * @param cls closure |
228 | * @param rd result data to clean up | 231 | * @param rd result data to clean up |
229 | */ | 232 | */ |
230 | typedef void | 233 | typedef void (*GNUNET_PQ_ResultCleanup) (void *cls, void *rd); |
231 | (*GNUNET_PQ_ResultCleanup)(void *cls, | ||
232 | void *rd); | ||
233 | 234 | ||
234 | 235 | ||
235 | /** | 236 | /** |
@@ -275,7 +276,6 @@ struct GNUNET_PQ_ResultSpec | |||
275 | * Where to store actual size of the result. | 276 | * Where to store actual size of the result. |
276 | */ | 277 | */ |
277 | size_t *result_size; | 278 | size_t *result_size; |
278 | |||
279 | }; | 279 | }; |
280 | 280 | ||
281 | 281 | ||
@@ -284,7 +284,10 @@ struct GNUNET_PQ_ResultSpec | |||
284 | * | 284 | * |
285 | * @return array last entry for the result specification to use | 285 | * @return array last entry for the result specification to use |
286 | */ | 286 | */ |
287 | #define GNUNET_PQ_result_spec_end { NULL, NULL, NULL, NULL, 0, NULL, NULL } | 287 | #define GNUNET_PQ_result_spec_end \ |
288 | { \ | ||
289 | NULL, NULL, NULL, NULL, 0, NULL, NULL \ | ||
290 | } | ||
288 | 291 | ||
289 | 292 | ||
290 | /** | 293 | /** |
@@ -297,8 +300,8 @@ struct GNUNET_PQ_ResultSpec | |||
297 | */ | 300 | */ |
298 | struct GNUNET_PQ_ResultSpec | 301 | struct GNUNET_PQ_ResultSpec |
299 | GNUNET_PQ_result_spec_variable_size (const char *name, | 302 | GNUNET_PQ_result_spec_variable_size (const char *name, |
300 | void **dst, | 303 | void **dst, |
301 | size_t *sptr); | 304 | size_t *sptr); |
302 | 305 | ||
303 | 306 | ||
304 | /** | 307 | /** |
@@ -310,10 +313,7 @@ GNUNET_PQ_result_spec_variable_size (const char *name, | |||
310 | * @return array entry for the result specification to use | 313 | * @return array entry for the result specification to use |
311 | */ | 314 | */ |
312 | struct GNUNET_PQ_ResultSpec | 315 | struct GNUNET_PQ_ResultSpec |
313 | GNUNET_PQ_result_spec_fixed_size (const char *name, | 316 | GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size); |
314 | void *dst, | ||
315 | size_t dst_size); | ||
316 | |||
317 | 317 | ||
318 | 318 | ||
319 | /** | 319 | /** |
@@ -323,7 +323,8 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, | |||
323 | * @param dst point to where to store the result, type fits expected result size | 323 | * @param dst point to where to store the result, type fits expected result size |
324 | * @return array entry for the result specification to use | 324 | * @return array entry for the result specification to use |
325 | */ | 325 | */ |
326 | #define GNUNET_PQ_result_spec_auto_from_type(name, dst) GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof (*(dst))) | 326 | #define GNUNET_PQ_result_spec_auto_from_type(name, dst) \ |
327 | GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof (*(dst))) | ||
327 | 328 | ||
328 | 329 | ||
329 | /** | 330 | /** |
@@ -334,8 +335,7 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, | |||
334 | * @return array entry for the result specification to use | 335 | * @return array entry for the result specification to use |
335 | */ | 336 | */ |
336 | struct GNUNET_PQ_ResultSpec | 337 | struct GNUNET_PQ_ResultSpec |
337 | GNUNET_PQ_result_spec_string (const char *name, | 338 | GNUNET_PQ_result_spec_string (const char *name, char **dst); |
338 | char **dst); | ||
339 | 339 | ||
340 | 340 | ||
341 | /** | 341 | /** |
@@ -347,7 +347,7 @@ GNUNET_PQ_result_spec_string (const char *name, | |||
347 | */ | 347 | */ |
348 | struct GNUNET_PQ_ResultSpec | 348 | struct GNUNET_PQ_ResultSpec |
349 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, | 349 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, |
350 | struct GNUNET_CRYPTO_RsaPublicKey **rsa); | 350 | struct GNUNET_CRYPTO_RsaPublicKey **rsa); |
351 | 351 | ||
352 | 352 | ||
353 | /** | 353 | /** |
@@ -359,7 +359,7 @@ GNUNET_PQ_result_spec_rsa_public_key (const char *name, | |||
359 | */ | 359 | */ |
360 | struct GNUNET_PQ_ResultSpec | 360 | struct GNUNET_PQ_ResultSpec |
361 | GNUNET_PQ_result_spec_rsa_signature (const char *name, | 361 | GNUNET_PQ_result_spec_rsa_signature (const char *name, |
362 | struct GNUNET_CRYPTO_RsaSignature **sig); | 362 | struct GNUNET_CRYPTO_RsaSignature **sig); |
363 | 363 | ||
364 | 364 | ||
365 | /** | 365 | /** |
@@ -371,7 +371,7 @@ GNUNET_PQ_result_spec_rsa_signature (const char *name, | |||
371 | */ | 371 | */ |
372 | struct GNUNET_PQ_ResultSpec | 372 | struct GNUNET_PQ_ResultSpec |
373 | GNUNET_PQ_result_spec_absolute_time (const char *name, | 373 | GNUNET_PQ_result_spec_absolute_time (const char *name, |
374 | struct GNUNET_TIME_Absolute *at); | 374 | struct GNUNET_TIME_Absolute *at); |
375 | 375 | ||
376 | 376 | ||
377 | /** | 377 | /** |
@@ -383,7 +383,7 @@ GNUNET_PQ_result_spec_absolute_time (const char *name, | |||
383 | */ | 383 | */ |
384 | struct GNUNET_PQ_ResultSpec | 384 | struct GNUNET_PQ_ResultSpec |
385 | GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, | 385 | GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, |
386 | struct GNUNET_TIME_AbsoluteNBO *at); | 386 | struct GNUNET_TIME_AbsoluteNBO *at); |
387 | 387 | ||
388 | 388 | ||
389 | /** | 389 | /** |
@@ -394,8 +394,7 @@ GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, | |||
394 | * @return array entry for the result specification to use | 394 | * @return array entry for the result specification to use |
395 | */ | 395 | */ |
396 | struct GNUNET_PQ_ResultSpec | 396 | struct GNUNET_PQ_ResultSpec |
397 | GNUNET_PQ_result_spec_uint16 (const char *name, | 397 | GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16); |
398 | uint16_t *u16); | ||
399 | 398 | ||
400 | 399 | ||
401 | /** | 400 | /** |
@@ -406,8 +405,7 @@ GNUNET_PQ_result_spec_uint16 (const char *name, | |||
406 | * @return array entry for the result specification to use | 405 | * @return array entry for the result specification to use |
407 | */ | 406 | */ |
408 | struct GNUNET_PQ_ResultSpec | 407 | struct GNUNET_PQ_ResultSpec |
409 | GNUNET_PQ_result_spec_uint32 (const char *name, | 408 | GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32); |
410 | uint32_t *u32); | ||
411 | 409 | ||
412 | 410 | ||
413 | /** | 411 | /** |
@@ -418,8 +416,7 @@ GNUNET_PQ_result_spec_uint32 (const char *name, | |||
418 | * @return array entry for the result specification to use | 416 | * @return array entry for the result specification to use |
419 | */ | 417 | */ |
420 | struct GNUNET_PQ_ResultSpec | 418 | struct GNUNET_PQ_ResultSpec |
421 | GNUNET_PQ_result_spec_uint64 (const char *name, | 419 | GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64); |
422 | uint64_t *u64); | ||
423 | 420 | ||
424 | 421 | ||
425 | /* ************************* pq.c functions ************************ */ | 422 | /* ************************* pq.c functions ************************ */ |
@@ -435,8 +432,8 @@ GNUNET_PQ_result_spec_uint64 (const char *name, | |||
435 | */ | 432 | */ |
436 | PGresult * | 433 | PGresult * |
437 | GNUNET_PQ_exec_prepared (PGconn *db_conn, | 434 | GNUNET_PQ_exec_prepared (PGconn *db_conn, |
438 | const char *name, | 435 | const char *name, |
439 | const struct GNUNET_PQ_QueryParam *params); | 436 | const struct GNUNET_PQ_QueryParam *params); |
440 | 437 | ||
441 | 438 | ||
442 | /** | 439 | /** |
@@ -452,8 +449,8 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn, | |||
452 | */ | 449 | */ |
453 | int | 450 | int |
454 | GNUNET_PQ_extract_result (PGresult *result, | 451 | GNUNET_PQ_extract_result (PGresult *result, |
455 | struct GNUNET_PQ_ResultSpec *rs, | 452 | struct GNUNET_PQ_ResultSpec *rs, |
456 | int row); | 453 | int row); |
457 | 454 | ||
458 | 455 | ||
459 | /** | 456 | /** |
@@ -518,10 +515,9 @@ GNUNET_PQ_eval_prepared_non_select (PGconn *connection, | |||
518 | * @param result the postgres result | 515 | * @param result the postgres result |
519 | * @param num_result the number of results in @a result | 516 | * @param num_result the number of results in @a result |
520 | */ | 517 | */ |
521 | typedef void | 518 | typedef void (*GNUNET_PQ_PostgresResultHandler) (void *cls, |
522 | (*GNUNET_PQ_PostgresResultHandler)(void *cls, | 519 | PGresult *result, |
523 | PGresult *result, | 520 | unsigned int num_results); |
524 | unsigned int num_results); | ||
525 | 521 | ||
526 | 522 | ||
527 | /** | 523 | /** |
@@ -563,10 +559,11 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, | |||
563 | * codes to `enum GNUNET_DB_QueryStatus`. | 559 | * codes to `enum GNUNET_DB_QueryStatus`. |
564 | */ | 560 | */ |
565 | enum GNUNET_DB_QueryStatus | 561 | enum GNUNET_DB_QueryStatus |
566 | GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, | 562 | GNUNET_PQ_eval_prepared_singleton_select ( |
567 | const char *statement_name, | 563 | PGconn *connection, |
568 | const struct GNUNET_PQ_QueryParam *params, | 564 | const char *statement_name, |
569 | struct GNUNET_PQ_ResultSpec *rs); | 565 | const struct GNUNET_PQ_QueryParam *params, |
566 | struct GNUNET_PQ_ResultSpec *rs); | ||
570 | 567 | ||
571 | 568 | ||
572 | /* ******************** pq_prepare.c functions ************** */ | 569 | /* ******************** pq_prepare.c functions ************** */ |
@@ -576,7 +573,8 @@ GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, | |||
576 | * Information needed to prepare a list of SQL statements using | 573 | * Information needed to prepare a list of SQL statements using |
577 | * #GNUNET_PQ_prepare_statements(). | 574 | * #GNUNET_PQ_prepare_statements(). |
578 | */ | 575 | */ |
579 | struct GNUNET_PQ_PreparedStatement { | 576 | struct GNUNET_PQ_PreparedStatement |
577 | { | ||
580 | 578 | ||
581 | /** | 579 | /** |
582 | * Name of the statement. | 580 | * Name of the statement. |
@@ -592,14 +590,16 @@ struct GNUNET_PQ_PreparedStatement { | |||
592 | * Number of arguments included in @e sql. | 590 | * Number of arguments included in @e sql. |
593 | */ | 591 | */ |
594 | unsigned int num_arguments; | 592 | unsigned int num_arguments; |
595 | |||
596 | }; | 593 | }; |
597 | 594 | ||
598 | 595 | ||
599 | /** | 596 | /** |
600 | * Terminator for prepared statement list. | 597 | * Terminator for prepared statement list. |
601 | */ | 598 | */ |
602 | #define GNUNET_PQ_PREPARED_STATEMENT_END { NULL, NULL, 0 } | 599 | #define GNUNET_PQ_PREPARED_STATEMENT_END \ |
600 | { \ | ||
601 | NULL, NULL, 0 \ | ||
602 | } | ||
603 | 603 | ||
604 | 604 | ||
605 | /** | 605 | /** |
@@ -637,7 +637,8 @@ GNUNET_PQ_prepare_statements (PGconn *connection, | |||
637 | * Information needed to run a list of SQL statements using | 637 | * Information needed to run a list of SQL statements using |
638 | * #GNUNET_PQ_exec_statements(). | 638 | * #GNUNET_PQ_exec_statements(). |
639 | */ | 639 | */ |
640 | struct GNUNET_PQ_ExecuteStatement { | 640 | struct GNUNET_PQ_ExecuteStatement |
641 | { | ||
641 | 642 | ||
642 | /** | 643 | /** |
643 | * Actual SQL statement. | 644 | * Actual SQL statement. |
@@ -648,14 +649,16 @@ struct GNUNET_PQ_ExecuteStatement { | |||
648 | * Should we ignore errors? | 649 | * Should we ignore errors? |
649 | */ | 650 | */ |
650 | int ignore_errors; | 651 | int ignore_errors; |
651 | |||
652 | }; | 652 | }; |
653 | 653 | ||
654 | 654 | ||
655 | /** | 655 | /** |
656 | * Terminator for executable statement list. | 656 | * Terminator for executable statement list. |
657 | */ | 657 | */ |
658 | #define GNUNET_PQ_EXECUTE_STATEMENT_END { NULL, GNUNET_SYSERR } | 658 | #define GNUNET_PQ_EXECUTE_STATEMENT_END \ |
659 | { \ | ||
660 | NULL, GNUNET_SYSERR \ | ||
661 | } | ||
659 | 662 | ||
660 | 663 | ||
661 | /** | 664 | /** |
@@ -721,7 +724,6 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
721 | const char *section); | 724 | const char *section); |
722 | 725 | ||
723 | 726 | ||
724 | 727 | #endif /* GNUNET_PQ_LIB_H_ */ | |
725 | #endif /* GNUNET_PQ_LIB_H_ */ | ||
726 | 728 | ||
727 | /* end of include/gnunet_pq_lib.h */ | 729 | /* end of include/gnunet_pq_lib.h */ |