aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_sq_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_sq_lib.h')
-rw-r--r--src/include/gnunet_sq_lib.h99
1 files changed, 54 insertions, 45 deletions
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h
index 31ac0675c..b6b09eb67 100644
--- a/src/include/gnunet_sq_lib.h
+++ b/src/include/gnunet_sq_lib.h
@@ -51,7 +51,8 @@ typedef int
51/** 51/**
52 * @brief Description of a DB query parameter. 52 * @brief Description of a DB query parameter.
53 */ 53 */
54struct GNUNET_SQ_QueryParam { 54struct GNUNET_SQ_QueryParam
55{
55 /** 56 /**
56 * Function for how to handle this type of entry. 57 * Function for how to handle this type of entry.
57 */ 58 */
@@ -93,8 +94,8 @@ struct GNUNET_SQ_QueryParam {
93 * @oaran ptr_size number of bytes in @a ptr 94 * @oaran ptr_size number of bytes in @a ptr
94 */ 95 */
95struct GNUNET_SQ_QueryParam 96struct GNUNET_SQ_QueryParam
96GNUNET_SQ_query_param_fixed_size(const void *ptr, 97GNUNET_SQ_query_param_fixed_size (const void *ptr,
97 size_t ptr_size); 98 size_t ptr_size);
98 99
99 100
100 101
@@ -104,7 +105,7 @@ GNUNET_SQ_query_param_fixed_size(const void *ptr,
104 * @param ptr pointer to the string query parameter to pass 105 * @param ptr pointer to the string query parameter to pass
105 */ 106 */
106struct GNUNET_SQ_QueryParam 107struct GNUNET_SQ_QueryParam
107GNUNET_SQ_query_param_string(const char *ptr); 108GNUNET_SQ_query_param_string (const char *ptr);
108 109
109 110
110/** 111/**
@@ -113,7 +114,8 @@ GNUNET_SQ_query_param_string(const char *ptr);
113 * 114 *
114 * @param x pointer to the query parameter to pass. 115 * @param x pointer to the query parameter to pass.
115 */ 116 */
116#define GNUNET_SQ_query_param_auto_from_type(x) GNUNET_SQ_query_param_fixed_size((x), sizeof(*(x))) 117#define GNUNET_SQ_query_param_auto_from_type( \
118 x) GNUNET_SQ_query_param_fixed_size ((x), sizeof(*(x)))
117 119
118 120
119/** 121/**
@@ -123,7 +125,8 @@ GNUNET_SQ_query_param_string(const char *ptr);
123 * @param x the query parameter to pass. 125 * @param x the query parameter to pass.
124 */ 126 */
125struct GNUNET_SQ_QueryParam 127struct GNUNET_SQ_QueryParam
126GNUNET_SQ_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x); 128GNUNET_SQ_query_param_rsa_public_key (const struct
129 GNUNET_CRYPTO_RsaPublicKey *x);
127 130
128 131
129/** 132/**
@@ -133,7 +136,8 @@ GNUNET_SQ_query_param_rsa_public_key(const struct GNUNET_CRYPTO_RsaPublicKey *x)
133 * @param x the query parameter to pass 136 * @param x the query parameter to pass
134 */ 137 */
135struct GNUNET_SQ_QueryParam 138struct GNUNET_SQ_QueryParam
136GNUNET_SQ_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x); 139GNUNET_SQ_query_param_rsa_signature (const struct
140 GNUNET_CRYPTO_RsaSignature *x);
137 141
138 142
139/** 143/**
@@ -143,7 +147,7 @@ GNUNET_SQ_query_param_rsa_signature(const struct GNUNET_CRYPTO_RsaSignature *x);
143 * @param x pointer to the query parameter to pass 147 * @param x pointer to the query parameter to pass
144 */ 148 */
145struct GNUNET_SQ_QueryParam 149struct GNUNET_SQ_QueryParam
146GNUNET_SQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x); 150GNUNET_SQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x);
147 151
148 152
149/** 153/**
@@ -153,7 +157,8 @@ GNUNET_SQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x);
153 * @param x pointer to the query parameter to pass 157 * @param x pointer to the query parameter to pass
154 */ 158 */
155struct GNUNET_SQ_QueryParam 159struct GNUNET_SQ_QueryParam
156GNUNET_SQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x); 160GNUNET_SQ_query_param_absolute_time_nbo (const struct
161 GNUNET_TIME_AbsoluteNBO *x);
157 162
158 163
159/** 164/**
@@ -162,7 +167,7 @@ GNUNET_SQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x)
162 * @param x pointer to the query parameter to pass 167 * @param x pointer to the query parameter to pass
163 */ 168 */
164struct GNUNET_SQ_QueryParam 169struct GNUNET_SQ_QueryParam
165GNUNET_SQ_query_param_uint16(const uint16_t *x); 170GNUNET_SQ_query_param_uint16 (const uint16_t *x);
166 171
167 172
168/** 173/**
@@ -171,7 +176,7 @@ GNUNET_SQ_query_param_uint16(const uint16_t *x);
171 * @param x pointer to the query parameter to pass 176 * @param x pointer to the query parameter to pass
172 */ 177 */
173struct GNUNET_SQ_QueryParam 178struct GNUNET_SQ_QueryParam
174GNUNET_SQ_query_param_uint32(const uint32_t *x); 179GNUNET_SQ_query_param_uint32 (const uint32_t *x);
175 180
176 181
177/** 182/**
@@ -180,7 +185,7 @@ GNUNET_SQ_query_param_uint32(const uint32_t *x);
180 * @param x pointer to the query parameter to pass 185 * @param x pointer to the query parameter to pass
181 */ 186 */
182struct GNUNET_SQ_QueryParam 187struct GNUNET_SQ_QueryParam
183GNUNET_SQ_query_param_uint64(const uint64_t *x); 188GNUNET_SQ_query_param_uint64 (const uint64_t *x);
184 189
185 190
186/** 191/**
@@ -191,8 +196,8 @@ GNUNET_SQ_query_param_uint64(const uint64_t *x);
191 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 196 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
192 */ 197 */
193int 198int
194GNUNET_SQ_bind(sqlite3_stmt *stmt, 199GNUNET_SQ_bind (sqlite3_stmt *stmt,
195 const struct GNUNET_SQ_QueryParam *params); 200 const struct GNUNET_SQ_QueryParam *params);
196 201
197 202
198/** 203/**
@@ -202,8 +207,8 @@ GNUNET_SQ_bind(sqlite3_stmt *stmt,
202 * @param stmt statement to reset 207 * @param stmt statement to reset
203 */ 208 */
204void 209void
205GNUNET_SQ_reset(sqlite3 *dbh, 210GNUNET_SQ_reset (sqlite3 *dbh,
206 sqlite3_stmt *stmt); 211 sqlite3_stmt *stmt);
207 212
208 213
209/** 214/**
@@ -245,7 +250,8 @@ typedef void
245/** 250/**
246 * @brief Description of a DB result cell. 251 * @brief Description of a DB result cell.
247 */ 252 */
248struct GNUNET_SQ_ResultSpec { 253struct GNUNET_SQ_ResultSpec
254{
249 /** 255 /**
250 * What is the format of the result? 256 * What is the format of the result?
251 */ 257 */
@@ -304,8 +310,8 @@ struct GNUNET_SQ_ResultSpec {
304 * @return array entry for the result specification to use 310 * @return array entry for the result specification to use
305 */ 311 */
306struct GNUNET_SQ_ResultSpec 312struct GNUNET_SQ_ResultSpec
307GNUNET_SQ_result_spec_variable_size(void **dst, 313GNUNET_SQ_result_spec_variable_size (void **dst,
308 size_t *sptr); 314 size_t *sptr);
309 315
310 316
311/** 317/**
@@ -316,8 +322,8 @@ GNUNET_SQ_result_spec_variable_size(void **dst,
316 * @return array entry for the result specification to use 322 * @return array entry for the result specification to use
317 */ 323 */
318struct GNUNET_SQ_ResultSpec 324struct GNUNET_SQ_ResultSpec
319GNUNET_SQ_result_spec_fixed_size(void *dst, 325GNUNET_SQ_result_spec_fixed_size (void *dst,
320 size_t dst_size); 326 size_t dst_size);
321 327
322 328
323/** 329/**
@@ -326,7 +332,8 @@ GNUNET_SQ_result_spec_fixed_size(void *dst,
326 * @param dst point to where to store the result, type fits expected result size 332 * @param dst point to where to store the result, type fits expected result size
327 * @return array entry for the result specification to use 333 * @return array entry for the result specification to use
328 */ 334 */
329#define GNUNET_SQ_result_spec_auto_from_type(dst) GNUNET_SQ_result_spec_fixed_size((dst), sizeof(*(dst))) 335#define GNUNET_SQ_result_spec_auto_from_type( \
336 dst) GNUNET_SQ_result_spec_fixed_size ((dst), sizeof(*(dst)))
330 337
331 338
332/** 339/**
@@ -337,8 +344,8 @@ GNUNET_SQ_result_spec_fixed_size(void *dst,
337 * @return array entry for the result specification to use 344 * @return array entry for the result specification to use
338 */ 345 */
339struct GNUNET_SQ_ResultSpec 346struct GNUNET_SQ_ResultSpec
340GNUNET_SQ_result_spec_variable_size(void **dst, 347GNUNET_SQ_result_spec_variable_size (void **dst,
341 size_t *sptr); 348 size_t *sptr);
342 349
343 350
344/** 351/**
@@ -348,7 +355,7 @@ GNUNET_SQ_result_spec_variable_size(void **dst,
348 * @return array entry for the result specification to use 355 * @return array entry for the result specification to use
349 */ 356 */
350struct GNUNET_SQ_ResultSpec 357struct GNUNET_SQ_ResultSpec
351GNUNET_SQ_result_spec_string(char **dst); 358GNUNET_SQ_result_spec_string (char **dst);
352 359
353 360
354/** 361/**
@@ -358,7 +365,7 @@ GNUNET_SQ_result_spec_string(char **dst);
358 * @return array entry for the result specification to use 365 * @return array entry for the result specification to use
359 */ 366 */
360struct GNUNET_SQ_ResultSpec 367struct GNUNET_SQ_ResultSpec
361GNUNET_SQ_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa); 368GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa);
362 369
363 370
364/** 371/**
@@ -368,7 +375,7 @@ GNUNET_SQ_result_spec_rsa_public_key(struct GNUNET_CRYPTO_RsaPublicKey **rsa);
368 * @return array entry for the result specification to use 375 * @return array entry for the result specification to use
369 */ 376 */
370struct GNUNET_SQ_ResultSpec 377struct GNUNET_SQ_ResultSpec
371GNUNET_SQ_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig); 378GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig);
372 379
373 380
374/** 381/**
@@ -378,7 +385,7 @@ GNUNET_SQ_result_spec_rsa_signature(struct GNUNET_CRYPTO_RsaSignature **sig);
378 * @return array entry for the result specification to use 385 * @return array entry for the result specification to use
379 */ 386 */
380struct GNUNET_SQ_ResultSpec 387struct GNUNET_SQ_ResultSpec
381GNUNET_SQ_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at); 388GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at);
382 389
383 390
384/** 391/**
@@ -388,7 +395,7 @@ GNUNET_SQ_result_spec_absolute_time(struct GNUNET_TIME_Absolute *at);
388 * @return array entry for the result specification to use 395 * @return array entry for the result specification to use
389 */ 396 */
390struct GNUNET_SQ_ResultSpec 397struct GNUNET_SQ_ResultSpec
391GNUNET_SQ_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at); 398GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at);
392 399
393 400
394/** 401/**
@@ -398,7 +405,7 @@ GNUNET_SQ_result_spec_absolute_time_nbo(struct GNUNET_TIME_AbsoluteNBO *at);
398 * @return array entry for the result specification to use 405 * @return array entry for the result specification to use
399 */ 406 */
400struct GNUNET_SQ_ResultSpec 407struct GNUNET_SQ_ResultSpec
401GNUNET_SQ_result_spec_uint16(uint16_t *u16); 408GNUNET_SQ_result_spec_uint16 (uint16_t *u16);
402 409
403 410
404/** 411/**
@@ -408,7 +415,7 @@ GNUNET_SQ_result_spec_uint16(uint16_t *u16);
408 * @return array entry for the result specification to use 415 * @return array entry for the result specification to use
409 */ 416 */
410struct GNUNET_SQ_ResultSpec 417struct GNUNET_SQ_ResultSpec
411GNUNET_SQ_result_spec_uint32(uint32_t *u32); 418GNUNET_SQ_result_spec_uint32 (uint32_t *u32);
412 419
413 420
414/** 421/**
@@ -418,7 +425,7 @@ GNUNET_SQ_result_spec_uint32(uint32_t *u32);
418 * @return array entry for the result specification to use 425 * @return array entry for the result specification to use
419 */ 426 */
420struct GNUNET_SQ_ResultSpec 427struct GNUNET_SQ_ResultSpec
421GNUNET_SQ_result_spec_uint64(uint64_t *u64); 428GNUNET_SQ_result_spec_uint64 (uint64_t *u64);
422 429
423 430
424/** 431/**
@@ -431,8 +438,8 @@ GNUNET_SQ_result_spec_uint64(uint64_t *u64);
431 * #GNUNET_SYSERR if a result was invalid (non-existing field) 438 * #GNUNET_SYSERR if a result was invalid (non-existing field)
432 */ 439 */
433int 440int
434GNUNET_SQ_extract_result(sqlite3_stmt *result, 441GNUNET_SQ_extract_result (sqlite3_stmt *result,
435 struct GNUNET_SQ_ResultSpec *rs); 442 struct GNUNET_SQ_ResultSpec *rs);
436 443
437 444
438/** 445/**
@@ -442,7 +449,7 @@ GNUNET_SQ_extract_result(sqlite3_stmt *result,
442 * @param rs reult specification to clean up 449 * @param rs reult specification to clean up
443 */ 450 */
444void 451void
445GNUNET_SQ_cleanup_result(struct GNUNET_SQ_ResultSpec *rs); 452GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs);
446 453
447 454
448 455
@@ -453,7 +460,8 @@ GNUNET_SQ_cleanup_result(struct GNUNET_SQ_ResultSpec *rs);
453 * Information needed to run a list of SQL statements using 460 * Information needed to run a list of SQL statements using
454 * #GNUNET_SQ_exec_statements(). 461 * #GNUNET_SQ_exec_statements().
455 */ 462 */
456struct GNUNET_SQ_PrepareStatement { 463struct GNUNET_SQ_PrepareStatement
464{
457 /** 465 /**
458 * Actual SQL statement. 466 * Actual SQL statement.
459 */ 467 */
@@ -480,8 +488,8 @@ struct GNUNET_SQ_PrepareStatement {
480 * @return initialized struct 488 * @return initialized struct
481 */ 489 */
482struct GNUNET_SQ_PrepareStatement 490struct GNUNET_SQ_PrepareStatement
483GNUNET_SQ_make_prepare(const char *sql, 491GNUNET_SQ_make_prepare (const char *sql,
484 sqlite3_stmt **pstmt); 492 sqlite3_stmt **pstmt);
485 493
486 494
487 495
@@ -494,8 +502,8 @@ GNUNET_SQ_make_prepare(const char *sql,
494 * @return #GNUNET_OK on success 502 * @return #GNUNET_OK on success
495 */ 503 */
496int 504int
497GNUNET_SQ_prepare(sqlite3 *dbh, 505GNUNET_SQ_prepare (sqlite3 *dbh,
498 const struct GNUNET_SQ_PrepareStatement *ps); 506 const struct GNUNET_SQ_PrepareStatement *ps);
499 507
500 508
501/* ******************** sq_exec.c functions ************** */ 509/* ******************** sq_exec.c functions ************** */
@@ -505,7 +513,8 @@ GNUNET_SQ_prepare(sqlite3 *dbh,
505 * Information needed to run a list of SQL statements using 513 * Information needed to run a list of SQL statements using
506 * #GNUNET_SQ_exec_statements(). 514 * #GNUNET_SQ_exec_statements().
507 */ 515 */
508struct GNUNET_SQ_ExecuteStatement { 516struct GNUNET_SQ_ExecuteStatement
517{
509 /** 518 /**
510 * Actual SQL statement. 519 * Actual SQL statement.
511 */ 520 */
@@ -531,7 +540,7 @@ struct GNUNET_SQ_ExecuteStatement {
531 * @return initialized struct 540 * @return initialized struct
532 */ 541 */
533struct GNUNET_SQ_ExecuteStatement 542struct GNUNET_SQ_ExecuteStatement
534GNUNET_SQ_make_execute(const char *sql); 543GNUNET_SQ_make_execute (const char *sql);
535 544
536 545
537/** 546/**
@@ -542,7 +551,7 @@ GNUNET_SQ_make_execute(const char *sql);
542 * @return initialized struct 551 * @return initialized struct
543 */ 552 */
544struct GNUNET_SQ_ExecuteStatement 553struct GNUNET_SQ_ExecuteStatement
545GNUNET_SQ_make_try_execute(const char *sql); 554GNUNET_SQ_make_try_execute (const char *sql);
546 555
547 556
548/** 557/**
@@ -555,8 +564,8 @@ GNUNET_SQ_make_try_execute(const char *sql);
555 * #GNUNET_SYSERR on error 564 * #GNUNET_SYSERR on error
556 */ 565 */
557int 566int
558GNUNET_SQ_exec_statements(sqlite3 *dbh, 567GNUNET_SQ_exec_statements (sqlite3 *dbh,
559 const struct GNUNET_SQ_ExecuteStatement *es); 568 const struct GNUNET_SQ_ExecuteStatement *es);
560 569
561 570
562 571