summaryrefslogtreecommitdiff
path: root/src/include/gnunet_pq_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_pq_lib.h')
-rw-r--r--src/include/gnunet_pq_lib.h128
1 files changed, 66 insertions, 62 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index fcd886521..6c576c8ab 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -60,7 +60,8 @@ typedef int (*GNUNET_PQ_QueryConverter) (void *cls,
60/** 60/**
61 * @brief Description of a DB query parameter. 61 * @brief Description of a DB query parameter.
62 */ 62 */
63struct GNUNET_PQ_QueryParam { 63struct GNUNET_PQ_QueryParam
64{
64 /** 65 /**
65 * Function for how to handle this type of entry. 66 * Function for how to handle this type of entry.
66 */ 67 */
@@ -105,7 +106,7 @@ struct GNUNET_PQ_QueryParam {
105 * @oaran ptr_size number of bytes in @a ptr 106 * @oaran ptr_size number of bytes in @a ptr
106 */ 107 */
107struct GNUNET_PQ_QueryParam 108struct GNUNET_PQ_QueryParam
108GNUNET_PQ_query_param_fixed_size(const void *ptr, size_t ptr_size); 109GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size);
109 110
110 111
111/** 112/**
@@ -114,7 +115,7 @@ GNUNET_PQ_query_param_fixed_size(const void *ptr, size_t ptr_size);
114 * @param ptr pointer to the string query parameter to pass 115 * @param ptr pointer to the string query parameter to pass
115 */ 116 */
116struct GNUNET_PQ_QueryParam 117struct GNUNET_PQ_QueryParam
117GNUNET_PQ_query_param_string(const char *ptr); 118GNUNET_PQ_query_param_string (const char *ptr);
118 119
119 120
120/** 121/**
@@ -124,7 +125,7 @@ GNUNET_PQ_query_param_string(const char *ptr);
124 * @param x pointer to the query parameter to pass. 125 * @param x pointer to the query parameter to pass.
125 */ 126 */
126#define GNUNET_PQ_query_param_auto_from_type(x) \ 127#define GNUNET_PQ_query_param_auto_from_type(x) \
127 GNUNET_PQ_query_param_fixed_size((x), sizeof(*(x))) 128 GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x)))
128 129
129 130
130/** 131/**
@@ -134,7 +135,7 @@ GNUNET_PQ_query_param_string(const char *ptr);
134 * @param x the query parameter to pass. 135 * @param x the query parameter to pass.
135 */ 136 */
136struct GNUNET_PQ_QueryParam 137struct GNUNET_PQ_QueryParam
137GNUNET_PQ_query_param_rsa_public_key( 138GNUNET_PQ_query_param_rsa_public_key (
138 const struct GNUNET_CRYPTO_RsaPublicKey *x); 139 const struct GNUNET_CRYPTO_RsaPublicKey *x);
139 140
140 141
@@ -145,7 +146,7 @@ GNUNET_PQ_query_param_rsa_public_key(
145 * @param x the query parameter to pass 146 * @param x the query parameter to pass
146 */ 147 */
147struct GNUNET_PQ_QueryParam 148struct GNUNET_PQ_QueryParam
148GNUNET_PQ_query_param_rsa_signature( 149GNUNET_PQ_query_param_rsa_signature (
149 const struct GNUNET_CRYPTO_RsaSignature *x); 150 const struct GNUNET_CRYPTO_RsaSignature *x);
150 151
151 152
@@ -156,7 +157,7 @@ GNUNET_PQ_query_param_rsa_signature(
156 * @param x pointer to the query parameter to pass 157 * @param x pointer to the query parameter to pass
157 */ 158 */
158struct GNUNET_PQ_QueryParam 159struct GNUNET_PQ_QueryParam
159GNUNET_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x); 160GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x);
160 161
161 162
162/** 163/**
@@ -166,7 +167,7 @@ GNUNET_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x);
166 * @param x pointer to the query parameter to pass 167 * @param x pointer to the query parameter to pass
167 */ 168 */
168struct GNUNET_PQ_QueryParam 169struct GNUNET_PQ_QueryParam
169GNUNET_PQ_query_param_absolute_time_nbo( 170GNUNET_PQ_query_param_absolute_time_nbo (
170 const struct GNUNET_TIME_AbsoluteNBO *x); 171 const struct GNUNET_TIME_AbsoluteNBO *x);
171 172
172 173
@@ -176,7 +177,7 @@ GNUNET_PQ_query_param_absolute_time_nbo(
176 * @param x pointer to the query parameter to pass 177 * @param x pointer to the query parameter to pass
177 */ 178 */
178struct GNUNET_PQ_QueryParam 179struct GNUNET_PQ_QueryParam
179GNUNET_PQ_query_param_uint16(const uint16_t *x); 180GNUNET_PQ_query_param_uint16 (const uint16_t *x);
180 181
181 182
182/** 183/**
@@ -185,7 +186,7 @@ GNUNET_PQ_query_param_uint16(const uint16_t *x);
185 * @param x pointer to the query parameter to pass 186 * @param x pointer to the query parameter to pass
186 */ 187 */
187struct GNUNET_PQ_QueryParam 188struct GNUNET_PQ_QueryParam
188GNUNET_PQ_query_param_uint32(const uint32_t *x); 189GNUNET_PQ_query_param_uint32 (const uint32_t *x);
189 190
190 191
191/** 192/**
@@ -194,7 +195,7 @@ GNUNET_PQ_query_param_uint32(const uint32_t *x);
194 * @param x pointer to the query parameter to pass 195 * @param x pointer to the query parameter to pass
195 */ 196 */
196struct GNUNET_PQ_QueryParam 197struct GNUNET_PQ_QueryParam
197GNUNET_PQ_query_param_uint64(const uint64_t *x); 198GNUNET_PQ_query_param_uint64 (const uint64_t *x);
198 199
199 200
200/* ************************* pq_result_helper.c functions ************************ */ 201/* ************************* pq_result_helper.c functions ************************ */
@@ -234,7 +235,8 @@ typedef void (*GNUNET_PQ_ResultCleanup) (void *cls, void *rd);
234/** 235/**
235 * @brief Description of a DB result cell. 236 * @brief Description of a DB result cell.
236 */ 237 */
237struct GNUNET_PQ_ResultSpec { 238struct GNUNET_PQ_ResultSpec
239{
238 /** 240 /**
239 * What is the format of the result? 241 * What is the format of the result?
240 */ 242 */
@@ -295,9 +297,9 @@ struct GNUNET_PQ_ResultSpec {
295 * @return array entry for the result specification to use 297 * @return array entry for the result specification to use
296 */ 298 */
297struct GNUNET_PQ_ResultSpec 299struct GNUNET_PQ_ResultSpec
298GNUNET_PQ_result_spec_variable_size(const char *name, 300GNUNET_PQ_result_spec_variable_size (const char *name,
299 void **dst, 301 void **dst,
300 size_t *sptr); 302 size_t *sptr);
301 303
302 304
303/** 305/**
@@ -309,7 +311,7 @@ GNUNET_PQ_result_spec_variable_size(const char *name,
309 * @return array entry for the result specification to use 311 * @return array entry for the result specification to use
310 */ 312 */
311struct GNUNET_PQ_ResultSpec 313struct GNUNET_PQ_ResultSpec
312GNUNET_PQ_result_spec_fixed_size(const char *name, void *dst, size_t dst_size); 314GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size);
313 315
314 316
315/** 317/**
@@ -320,7 +322,7 @@ GNUNET_PQ_result_spec_fixed_size(const char *name, void *dst, size_t dst_size);
320 * @return array entry for the result specification to use 322 * @return array entry for the result specification to use
321 */ 323 */
322#define GNUNET_PQ_result_spec_auto_from_type(name, dst) \ 324#define GNUNET_PQ_result_spec_auto_from_type(name, dst) \
323 GNUNET_PQ_result_spec_fixed_size(name, (dst), sizeof(*(dst))) 325 GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst)))
324 326
325 327
326/** 328/**
@@ -331,7 +333,7 @@ GNUNET_PQ_result_spec_fixed_size(const char *name, void *dst, size_t dst_size);
331 * @return array entry for the result specification to use 333 * @return array entry for the result specification to use
332 */ 334 */
333struct GNUNET_PQ_ResultSpec 335struct GNUNET_PQ_ResultSpec
334GNUNET_PQ_result_spec_string(const char *name, char **dst); 336GNUNET_PQ_result_spec_string (const char *name, char **dst);
335 337
336 338
337/** 339/**
@@ -342,8 +344,8 @@ GNUNET_PQ_result_spec_string(const char *name, char **dst);
342 * @return array entry for the result specification to use 344 * @return array entry for the result specification to use
343 */ 345 */
344struct GNUNET_PQ_ResultSpec 346struct GNUNET_PQ_ResultSpec
345GNUNET_PQ_result_spec_rsa_public_key(const char *name, 347GNUNET_PQ_result_spec_rsa_public_key (const char *name,
346 struct GNUNET_CRYPTO_RsaPublicKey **rsa); 348 struct GNUNET_CRYPTO_RsaPublicKey **rsa);
347 349
348 350
349/** 351/**
@@ -354,8 +356,8 @@ GNUNET_PQ_result_spec_rsa_public_key(const char *name,
354 * @return array entry for the result specification to use 356 * @return array entry for the result specification to use
355 */ 357 */
356struct GNUNET_PQ_ResultSpec 358struct GNUNET_PQ_ResultSpec
357GNUNET_PQ_result_spec_rsa_signature(const char *name, 359GNUNET_PQ_result_spec_rsa_signature (const char *name,
358 struct GNUNET_CRYPTO_RsaSignature **sig); 360 struct GNUNET_CRYPTO_RsaSignature **sig);
359 361
360 362
361/** 363/**
@@ -366,8 +368,8 @@ GNUNET_PQ_result_spec_rsa_signature(const char *name,
366 * @return array entry for the result specification to use 368 * @return array entry for the result specification to use
367 */ 369 */
368struct GNUNET_PQ_ResultSpec 370struct GNUNET_PQ_ResultSpec
369GNUNET_PQ_result_spec_absolute_time(const char *name, 371GNUNET_PQ_result_spec_absolute_time (const char *name,
370 struct GNUNET_TIME_Absolute *at); 372 struct GNUNET_TIME_Absolute *at);
371 373
372 374
373/** 375/**
@@ -378,8 +380,8 @@ GNUNET_PQ_result_spec_absolute_time(const char *name,
378 * @return array entry for the result specification to use 380 * @return array entry for the result specification to use
379 */ 381 */
380struct GNUNET_PQ_ResultSpec 382struct GNUNET_PQ_ResultSpec
381GNUNET_PQ_result_spec_absolute_time_nbo(const char *name, 383GNUNET_PQ_result_spec_absolute_time_nbo (const char *name,
382 struct GNUNET_TIME_AbsoluteNBO *at); 384 struct GNUNET_TIME_AbsoluteNBO *at);
383 385
384 386
385/** 387/**
@@ -390,7 +392,7 @@ GNUNET_PQ_result_spec_absolute_time_nbo(const char *name,
390 * @return array entry for the result specification to use 392 * @return array entry for the result specification to use
391 */ 393 */
392struct GNUNET_PQ_ResultSpec 394struct GNUNET_PQ_ResultSpec
393GNUNET_PQ_result_spec_uint16(const char *name, uint16_t *u16); 395GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16);
394 396
395 397
396/** 398/**
@@ -401,7 +403,7 @@ GNUNET_PQ_result_spec_uint16(const char *name, uint16_t *u16);
401 * @return array entry for the result specification to use 403 * @return array entry for the result specification to use
402 */ 404 */
403struct GNUNET_PQ_ResultSpec 405struct GNUNET_PQ_ResultSpec
404GNUNET_PQ_result_spec_uint32(const char *name, uint32_t *u32); 406GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32);
405 407
406 408
407/** 409/**
@@ -412,7 +414,7 @@ GNUNET_PQ_result_spec_uint32(const char *name, uint32_t *u32);
412 * @return array entry for the result specification to use 414 * @return array entry for the result specification to use
413 */ 415 */
414struct GNUNET_PQ_ResultSpec 416struct GNUNET_PQ_ResultSpec
415GNUNET_PQ_result_spec_uint64(const char *name, uint64_t *u64); 417GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64);
416 418
417 419
418/* ************************* pq.c functions ************************ */ 420/* ************************* pq.c functions ************************ */
@@ -427,9 +429,9 @@ GNUNET_PQ_result_spec_uint64(const char *name, uint64_t *u64);
427 * @deprecated (should become an internal API) 429 * @deprecated (should become an internal API)
428 */ 430 */
429PGresult * 431PGresult *
430GNUNET_PQ_exec_prepared(PGconn *db_conn, 432GNUNET_PQ_exec_prepared (PGconn *db_conn,
431 const char *name, 433 const char *name,
432 const struct GNUNET_PQ_QueryParam *params); 434 const struct GNUNET_PQ_QueryParam *params);
433 435
434 436
435/** 437/**
@@ -444,9 +446,9 @@ GNUNET_PQ_exec_prepared(PGconn *db_conn,
444 * @deprecated (should become an internal API) 446 * @deprecated (should become an internal API)
445 */ 447 */
446int 448int
447GNUNET_PQ_extract_result(PGresult *result, 449GNUNET_PQ_extract_result (PGresult *result,
448 struct GNUNET_PQ_ResultSpec *rs, 450 struct GNUNET_PQ_ResultSpec *rs,
449 int row); 451 int row);
450 452
451 453
452/** 454/**
@@ -456,7 +458,7 @@ GNUNET_PQ_extract_result(PGresult *result,
456 * @param rs reult specification to clean up 458 * @param rs reult specification to clean up
457 */ 459 */
458void 460void
459GNUNET_PQ_cleanup_result(struct GNUNET_PQ_ResultSpec *rs); 461GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs);
460 462
461 463
462/* ******************** pq_eval.c functions ************** */ 464/* ******************** pq_eval.c functions ************** */
@@ -476,9 +478,9 @@ GNUNET_PQ_cleanup_result(struct GNUNET_PQ_ResultSpec *rs);
476 * @deprecated (low level, let's see if we can do with just the high-level functions) 478 * @deprecated (low level, let's see if we can do with just the high-level functions)
477 */ 479 */
478enum GNUNET_DB_QueryStatus 480enum GNUNET_DB_QueryStatus
479GNUNET_PQ_eval_result(PGconn *connection, 481GNUNET_PQ_eval_result (PGconn *connection,
480 const char *statement_name, 482 const char *statement_name,
481 PGresult *result); 483 PGresult *result);
482 484
483 485
484/** 486/**
@@ -498,9 +500,9 @@ GNUNET_PQ_eval_result(PGconn *connection,
498 * zero; if INSERT was successful, we return one. 500 * zero; if INSERT was successful, we return one.
499 */ 501 */
500enum GNUNET_DB_QueryStatus 502enum GNUNET_DB_QueryStatus
501GNUNET_PQ_eval_prepared_non_select(PGconn *connection, 503GNUNET_PQ_eval_prepared_non_select (PGconn *connection,
502 const char *statement_name, 504 const char *statement_name,
503 const struct GNUNET_PQ_QueryParam *params); 505 const struct GNUNET_PQ_QueryParam *params);
504 506
505 507
506/** 508/**
@@ -532,11 +534,11 @@ typedef void (*GNUNET_PQ_PostgresResultHandler) (void *cls,
532 * codes to `enum GNUNET_DB_QueryStatus`. 534 * codes to `enum GNUNET_DB_QueryStatus`.
533 */ 535 */
534enum GNUNET_DB_QueryStatus 536enum GNUNET_DB_QueryStatus
535GNUNET_PQ_eval_prepared_multi_select(PGconn *connection, 537GNUNET_PQ_eval_prepared_multi_select (PGconn *connection,
536 const char *statement_name, 538 const char *statement_name,
537 const struct GNUNET_PQ_QueryParam *params, 539 const struct GNUNET_PQ_QueryParam *params,
538 GNUNET_PQ_PostgresResultHandler rh, 540 GNUNET_PQ_PostgresResultHandler rh,
539 void *rh_cls); 541 void *rh_cls);
540 542
541 543
542/** 544/**
@@ -555,7 +557,7 @@ GNUNET_PQ_eval_prepared_multi_select(PGconn *connection,
555 * codes to `enum GNUNET_DB_QueryStatus`. 557 * codes to `enum GNUNET_DB_QueryStatus`.
556 */ 558 */
557enum GNUNET_DB_QueryStatus 559enum GNUNET_DB_QueryStatus
558GNUNET_PQ_eval_prepared_singleton_select( 560GNUNET_PQ_eval_prepared_singleton_select (
559 PGconn *connection, 561 PGconn *connection,
560 const char *statement_name, 562 const char *statement_name,
561 const struct GNUNET_PQ_QueryParam *params, 563 const struct GNUNET_PQ_QueryParam *params,
@@ -569,7 +571,8 @@ GNUNET_PQ_eval_prepared_singleton_select(
569 * Information needed to prepare a list of SQL statements using 571 * Information needed to prepare a list of SQL statements using
570 * #GNUNET_PQ_prepare_statements(). 572 * #GNUNET_PQ_prepare_statements().
571 */ 573 */
572struct GNUNET_PQ_PreparedStatement { 574struct GNUNET_PQ_PreparedStatement
575{
573 /** 576 /**
574 * Name of the statement. 577 * Name of the statement.
575 */ 578 */
@@ -605,9 +608,9 @@ struct GNUNET_PQ_PreparedStatement {
605 * @return initialized struct 608 * @return initialized struct
606 */ 609 */
607struct GNUNET_PQ_PreparedStatement 610struct GNUNET_PQ_PreparedStatement
608GNUNET_PQ_make_prepare(const char *name, 611GNUNET_PQ_make_prepare (const char *name,
609 const char *sql, 612 const char *sql,
610 unsigned int num_args); 613 unsigned int num_args);
611 614
612 615
613/** 616/**
@@ -620,8 +623,8 @@ GNUNET_PQ_make_prepare(const char *name,
620 * #GNUNET_SYSERR on error 623 * #GNUNET_SYSERR on error
621 */ 624 */
622int 625int
623GNUNET_PQ_prepare_statements(PGconn *connection, 626GNUNET_PQ_prepare_statements (PGconn *connection,
624 const struct GNUNET_PQ_PreparedStatement *ps); 627 const struct GNUNET_PQ_PreparedStatement *ps);
625 628
626 629
627/* ******************** pq_exec.c functions ************** */ 630/* ******************** pq_exec.c functions ************** */
@@ -631,7 +634,8 @@ GNUNET_PQ_prepare_statements(PGconn *connection,
631 * Information needed to run a list of SQL statements using 634 * Information needed to run a list of SQL statements using
632 * #GNUNET_PQ_exec_statements(). 635 * #GNUNET_PQ_exec_statements().
633 */ 636 */
634struct GNUNET_PQ_ExecuteStatement { 637struct GNUNET_PQ_ExecuteStatement
638{
635 /** 639 /**
636 * Actual SQL statement. 640 * Actual SQL statement.
637 */ 641 */
@@ -660,7 +664,7 @@ struct GNUNET_PQ_ExecuteStatement {
660 * @return initialized struct 664 * @return initialized struct
661 */ 665 */
662struct GNUNET_PQ_ExecuteStatement 666struct GNUNET_PQ_ExecuteStatement
663GNUNET_PQ_make_execute(const char *sql); 667GNUNET_PQ_make_execute (const char *sql);
664 668
665 669
666/** 670/**
@@ -671,7 +675,7 @@ GNUNET_PQ_make_execute(const char *sql);
671 * @return initialized struct 675 * @return initialized struct
672 */ 676 */
673struct GNUNET_PQ_ExecuteStatement 677struct GNUNET_PQ_ExecuteStatement
674GNUNET_PQ_make_try_execute(const char *sql); 678GNUNET_PQ_make_try_execute (const char *sql);
675 679
676 680
677/** 681/**
@@ -684,8 +688,8 @@ GNUNET_PQ_make_try_execute(const char *sql);
684 * #GNUNET_SYSERR on error 688 * #GNUNET_SYSERR on error
685 */ 689 */
686int 690int
687GNUNET_PQ_exec_statements(PGconn *connection, 691GNUNET_PQ_exec_statements (PGconn *connection,
688 const struct GNUNET_PQ_ExecuteStatement *es); 692 const struct GNUNET_PQ_ExecuteStatement *es);
689 693
690 694
691/* ******************** pq_connect.c functions ************** */ 695/* ******************** pq_connect.c functions ************** */
@@ -700,7 +704,7 @@ GNUNET_PQ_exec_statements(PGconn *connection,
700 * @return NULL on error 704 * @return NULL on error
701 */ 705 */
702PGconn * 706PGconn *
703GNUNET_PQ_connect(const char *config_str); 707GNUNET_PQ_connect (const char *config_str);
704 708
705 709
706/** 710/**
@@ -712,8 +716,8 @@ GNUNET_PQ_connect(const char *config_str);
712 * @return the postgres handle, NULL on error 716 * @return the postgres handle, NULL on error
713 */ 717 */
714PGconn * 718PGconn *
715GNUNET_PQ_connect_with_cfg(const struct GNUNET_CONFIGURATION_Handle *cfg, 719GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
716 const char *section); 720 const char *section);
717 721
718 722
719#endif /* GNUNET_PQ_LIB_H_ */ 723#endif /* GNUNET_PQ_LIB_H_ */