diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-09 17:33:04 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-09 17:33:04 +0200 |
commit | 8bb475af99260f1d107dbc8908268ae93960aa83 (patch) | |
tree | 1a7a1fc03424df841a6f977b137482439b09bc9f /src/include | |
parent | 1f80a11e90ee982bffaae4685e281f75ee1c225d (diff) | |
download | gnunet-8bb475af99260f1d107dbc8908268ae93960aa83.tar.gz gnunet-8bb475af99260f1d107dbc8908268ae93960aa83.zip |
implement new functions in libgnunetsq, clean up sqlite namestore plugin, implement flow control in namestore API and tests
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 12 | ||||
-rw-r--r-- | src/include/gnunet_sq_lib.h | 119 |
2 files changed, 131 insertions, 0 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index be2885460..114a22052 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -709,6 +709,18 @@ GNUNET_DISK_directory_remove (const char *filename); | |||
709 | 709 | ||
710 | 710 | ||
711 | /** | 711 | /** |
712 | * Remove the directory given under @a option in | ||
713 | * section [PATHS] in configuration under @a cfg_filename | ||
714 | * | ||
715 | * @param cfg_filename configuration file to parse | ||
716 | * @param option option with the dir name to purge | ||
717 | */ | ||
718 | void | ||
719 | GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, | ||
720 | const char *option); | ||
721 | |||
722 | |||
723 | /** | ||
712 | * Implementation of "mkdir -p" | 724 | * Implementation of "mkdir -p" |
713 | * | 725 | * |
714 | * @param dir the directory to create | 726 | * @param dir the directory to create |
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h index f3adbc4c2..61fd5299a 100644 --- a/src/include/gnunet_sq_lib.h +++ b/src/include/gnunet_sq_lib.h | |||
@@ -446,6 +446,125 @@ void | |||
446 | GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs); | 446 | GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs); |
447 | 447 | ||
448 | 448 | ||
449 | |||
450 | /* ******************** sq_prepare.c functions ************** */ | ||
451 | |||
452 | |||
453 | /** | ||
454 | * Information needed to run a list of SQL statements using | ||
455 | * #GNUNET_SQ_exec_statements(). | ||
456 | */ | ||
457 | struct GNUNET_SQ_PrepareStatement { | ||
458 | |||
459 | /** | ||
460 | * Actual SQL statement. | ||
461 | */ | ||
462 | const char *sql; | ||
463 | |||
464 | /** | ||
465 | * Where to store handle? | ||
466 | */ | ||
467 | sqlite3_stmt **pstmt; | ||
468 | |||
469 | }; | ||
470 | |||
471 | |||
472 | /** | ||
473 | * Terminator for executable statement list. | ||
474 | */ | ||
475 | #define GNUNET_SQ_PREPARE_END { NULL, NULL } | ||
476 | |||
477 | |||
478 | /** | ||
479 | * Create a `struct GNUNET_SQ_PrepareStatement` | ||
480 | * | ||
481 | * @param sql actual SQL statement | ||
482 | * @param pstmt where to store the handle | ||
483 | * @return initialized struct | ||
484 | */ | ||
485 | struct GNUNET_SQ_PrepareStatement | ||
486 | GNUNET_SQ_make_prepare (const char *sql, | ||
487 | sqlite3_stmt **pstmt); | ||
488 | |||
489 | |||
490 | |||
491 | /** | ||
492 | * Prepare all statements given in the (NULL,NULL)-terminated | ||
493 | * array at @a ps | ||
494 | * | ||
495 | * @param dbh database handle | ||
496 | * @param ps array of statements to prepare | ||
497 | * @return #GNUNET_OK on success | ||
498 | */ | ||
499 | int | ||
500 | GNUNET_SQ_prepare (sqlite3 *dbh, | ||
501 | const struct GNUNET_SQ_PrepareStatement *ps); | ||
502 | |||
503 | |||
504 | /* ******************** sq_exec.c functions ************** */ | ||
505 | |||
506 | |||
507 | /** | ||
508 | * Information needed to run a list of SQL statements using | ||
509 | * #GNUNET_SQ_exec_statements(). | ||
510 | */ | ||
511 | struct GNUNET_SQ_ExecuteStatement { | ||
512 | |||
513 | /** | ||
514 | * Actual SQL statement. | ||
515 | */ | ||
516 | const char *sql; | ||
517 | |||
518 | /** | ||
519 | * Should we ignore errors? | ||
520 | */ | ||
521 | int ignore_errors; | ||
522 | |||
523 | }; | ||
524 | |||
525 | |||
526 | /** | ||
527 | * Terminator for executable statement list. | ||
528 | */ | ||
529 | #define GNUNET_SQ_EXECUTE_STATEMENT_END { NULL, GNUNET_SYSERR } | ||
530 | |||
531 | |||
532 | /** | ||
533 | * Create a `struct GNUNET_SQ_ExecuteStatement` where errors are fatal. | ||
534 | * | ||
535 | * @param sql actual SQL statement | ||
536 | * @return initialized struct | ||
537 | */ | ||
538 | struct GNUNET_SQ_ExecuteStatement | ||
539 | GNUNET_SQ_make_execute (const char *sql); | ||
540 | |||
541 | |||
542 | /** | ||
543 | * Create a `struct GNUNET_SQ_ExecuteStatement` where errors should | ||
544 | * be tolerated. | ||
545 | * | ||
546 | * @param sql actual SQL statement | ||
547 | * @return initialized struct | ||
548 | */ | ||
549 | struct GNUNET_SQ_ExecuteStatement | ||
550 | GNUNET_SQ_make_try_execute (const char *sql); | ||
551 | |||
552 | |||
553 | /** | ||
554 | * Request execution of an array of statements @a es from Postgres. | ||
555 | * | ||
556 | * @param dbh database to execute the statements over | ||
557 | * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared | ||
558 | * statements. | ||
559 | * @return #GNUNET_OK on success (modulo statements where errors can be ignored) | ||
560 | * #GNUNET_SYSERR on error | ||
561 | */ | ||
562 | int | ||
563 | GNUNET_SQ_exec_statements (sqlite3 *dbh, | ||
564 | const struct GNUNET_SQ_ExecuteStatement *es); | ||
565 | |||
566 | |||
567 | |||
449 | #endif /* GNUNET_SQ_LIB_H_ */ | 568 | #endif /* GNUNET_SQ_LIB_H_ */ |
450 | 569 | ||
451 | /* end of include/gnunet_sq_lib.h */ | 570 | /* end of include/gnunet_sq_lib.h */ |