aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/plugin_namestore_sqlite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/plugin_namestore_sqlite.c')
-rw-r--r--src/namestore/plugin_namestore_sqlite.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 493981c06..1acb5aff2 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -136,7 +136,7 @@ sq_prepare (sqlite3 * dbh, const char *zSql, sqlite3_stmt ** ppStmt)
136 result = 136 result =
137 sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt, 137 sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt,
138 (const char **) &dummy); 138 (const char **) &dummy);
139 LOG (GNUNET_ERROR_TYPE_DEBUG, 139 LOG (GNUNET_ERROR_TYPE_DEBUG,
140 "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result); 140 "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result);
141 return result; 141 return result;
142} 142}
@@ -166,7 +166,7 @@ create_indices (sqlite3 * dbh)
166 (SQLITE_OK != 166 (SQLITE_OK !=
167 sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS it_iter ON ns096records (rvalue)", 167 sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS it_iter ON ns096records (rvalue)",
168 NULL, NULL, NULL)) ) 168 NULL, NULL, NULL)) )
169 LOG (GNUNET_ERROR_TYPE_ERROR, 169 LOG (GNUNET_ERROR_TYPE_ERROR,
170 "Failed to create indices: %s\n", sqlite3_errmsg (dbh)); 170 "Failed to create indices: %s\n", sqlite3_errmsg (dbh));
171} 171}
172 172
@@ -262,11 +262,11 @@ database_setup (struct Plugin *plugin)
262 if ((sqlite3_step (stmt) == SQLITE_DONE) && 262 if ((sqlite3_step (stmt) == SQLITE_DONE) &&
263 (sqlite3_exec 263 (sqlite3_exec
264 (plugin->dbh, 264 (plugin->dbh,
265 "CREATE TABLE ns096blocks (" 265 "CREATE TABLE ns096blocks ("
266 " query BLOB NOT NULL DEFAULT ''," 266 " query BLOB NOT NULL DEFAULT '',"
267 " block BLOB NOT NULL DEFAULT ''," 267 " block BLOB NOT NULL DEFAULT '',"
268 " expiration_time INT8 NOT NULL DEFAULT 0" 268 " expiration_time INT8 NOT NULL DEFAULT 0"
269 ")", 269 ")",
270 NULL, NULL, NULL) != SQLITE_OK)) 270 NULL, NULL, NULL) != SQLITE_OK))
271 { 271 {
272 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); 272 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
@@ -282,14 +282,14 @@ database_setup (struct Plugin *plugin)
282 if ((sqlite3_step (stmt) == SQLITE_DONE) && 282 if ((sqlite3_step (stmt) == SQLITE_DONE) &&
283 (sqlite3_exec 283 (sqlite3_exec
284 (plugin->dbh, 284 (plugin->dbh,
285 "CREATE TABLE ns096records (" 285 "CREATE TABLE ns096records ("
286 " zone_private_key BLOB NOT NULL DEFAULT ''," 286 " zone_private_key BLOB NOT NULL DEFAULT '',"
287 " pkey_hash BLOB," 287 " pkey_hash BLOB,"
288 " rvalue INT8 NOT NULL DEFAULT ''," 288 " rvalue INT8 NOT NULL DEFAULT '',"
289 " record_count INT NOT NULL DEFAULT 0," 289 " record_count INT NOT NULL DEFAULT 0,"
290 " record_data BLOB NOT NULL DEFAULT ''," 290 " record_data BLOB NOT NULL DEFAULT '',"
291 " label TEXT NOT NULL DEFAULT ''" 291 " label TEXT NOT NULL DEFAULT ''"
292 ")", 292 ")",
293 NULL, NULL, NULL) != SQLITE_OK)) 293 NULL, NULL, NULL) != SQLITE_OK))
294 { 294 {
295 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); 295 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
@@ -332,14 +332,14 @@ database_setup (struct Plugin *plugin)
332 &plugin->zone_to_name) != SQLITE_OK) || 332 &plugin->zone_to_name) != SQLITE_OK) ||
333 (sq_prepare 333 (sq_prepare
334 (plugin->dbh, 334 (plugin->dbh,
335 "SELECT record_count,record_data,label" 335 "SELECT record_count,record_data,label"
336 " FROM ns096records WHERE zone_private_key=? ORDER BY rvalue LIMIT 1 OFFSET ?", 336 " FROM ns096records WHERE zone_private_key=? ORDER BY rvalue LIMIT 1 OFFSET ?",
337 &plugin->iterate_zone) != SQLITE_OK) || 337 &plugin->iterate_zone) != SQLITE_OK) ||
338 (sq_prepare 338 (sq_prepare
339 (plugin->dbh, 339 (plugin->dbh,
340 "SELECT record_count,record_data,label,zone_private_key" 340 "SELECT record_count,record_data,label,zone_private_key"
341 " FROM ns096records ORDER BY rvalue LIMIT 1 OFFSET ?", 341 " FROM ns096records ORDER BY rvalue LIMIT 1 OFFSET ?",
342 &plugin->iterate_all_zones) != SQLITE_OK) 342 &plugin->iterate_all_zones) != SQLITE_OK)
343 ) 343 )
344 { 344 {
345 LOG_SQLITE (plugin,GNUNET_ERROR_TYPE_ERROR, "precompiling"); 345 LOG_SQLITE (plugin,GNUNET_ERROR_TYPE_ERROR, "precompiling");
@@ -415,7 +415,7 @@ namestore_sqlite_expire_blocks (struct Plugin *plugin)
415 int n; 415 int n;
416 416
417 now = GNUNET_TIME_absolute_get (); 417 now = GNUNET_TIME_absolute_get ();
418 if (SQLITE_OK != sqlite3_bind_int64 (plugin->expire_blocks, 418 if (SQLITE_OK != sqlite3_bind_int64 (plugin->expire_blocks,
419 1, now.abs_value_us)) 419 1, now.abs_value_us))
420 { 420 {
421 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 421 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -454,8 +454,8 @@ namestore_sqlite_expire_blocks (struct Plugin *plugin)
454 * @param block block to cache 454 * @param block block to cache
455 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 455 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
456 */ 456 */
457static int 457static int
458namestore_sqlite_cache_block (void *cls, 458namestore_sqlite_cache_block (void *cls,
459 const struct GNUNET_NAMESTORE_Block *block) 459 const struct GNUNET_NAMESTORE_Block *block)
460{ 460{
461 struct Plugin *plugin = cls; 461 struct Plugin *plugin = cls;
@@ -466,16 +466,16 @@ namestore_sqlite_cache_block (void *cls,
466 int n; 466 int n;
467 467
468 namestore_sqlite_expire_blocks (plugin); 468 namestore_sqlite_expire_blocks (plugin);
469 GNUNET_CRYPTO_hash (&block->derived_key, 469 GNUNET_CRYPTO_hash (&block->derived_key,
470 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 470 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
471 &query); 471 &query);
472 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); 472 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
473 dval = (int64_t) expiration.abs_value_us; 473 dval = (int64_t) expiration.abs_value_us;
474 if (dval < 0) 474 if (dval < 0)
475 dval = INT64_MAX; 475 dval = INT64_MAX;
476 block_size = ntohl (block->purpose.size) + 476 block_size = ntohl (block->purpose.size) +
477 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + 477 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) +
478 sizeof (struct GNUNET_CRYPTO_EccSignature); 478 sizeof (struct GNUNET_CRYPTO_EccSignature);
479 if (block_size > 64 * 65536) 479 if (block_size > 64 * 65536)
480 { 480 {
481 GNUNET_break (0); 481 GNUNET_break (0);
@@ -483,11 +483,11 @@ namestore_sqlite_cache_block (void *cls,
483 } 483 }
484 484
485 /* delete old version of the block */ 485 /* delete old version of the block */
486 if ( (SQLITE_OK != 486 if ( (SQLITE_OK !=
487 sqlite3_bind_blob (plugin->delete_block, 1, 487 sqlite3_bind_blob (plugin->delete_block, 1,
488 &query, sizeof (struct GNUNET_HashCode), 488 &query, sizeof (struct GNUNET_HashCode),
489 SQLITE_STATIC)) || 489 SQLITE_STATIC)) ||
490 (SQLITE_OK != 490 (SQLITE_OK !=
491 sqlite3_bind_int64 (plugin->delete_block, 491 sqlite3_bind_int64 (plugin->delete_block,
492 2, dval)) ) 492 2, dval)) )
493 { 493 {
@@ -519,30 +519,30 @@ namestore_sqlite_cache_block (void *cls,
519 "sqlite3_reset"); 519 "sqlite3_reset");
520 520
521 /* insert new version of the block */ 521 /* insert new version of the block */
522 if ((SQLITE_OK != 522 if ((SQLITE_OK !=
523 sqlite3_bind_blob (plugin->cache_block, 1, 523 sqlite3_bind_blob (plugin->cache_block, 1,
524 &query, sizeof (struct GNUNET_HashCode), 524 &query, sizeof (struct GNUNET_HashCode),
525 SQLITE_STATIC)) || 525 SQLITE_STATIC)) ||
526 (SQLITE_OK != 526 (SQLITE_OK !=
527 sqlite3_bind_blob (plugin->cache_block, 2, 527 sqlite3_bind_blob (plugin->cache_block, 2,
528 block, block_size, 528 block, block_size,
529 SQLITE_STATIC)) || 529 SQLITE_STATIC)) ||
530 (SQLITE_OK != 530 (SQLITE_OK !=
531 sqlite3_bind_int64 (plugin->cache_block, 3, 531 sqlite3_bind_int64 (plugin->cache_block, 3,
532 dval))) 532 dval)))
533 { 533 {
534 LOG_SQLITE (plugin, 534 LOG_SQLITE (plugin,
535 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 535 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
536 "sqlite3_bind_XXXX"); 536 "sqlite3_bind_XXXX");
537 if (SQLITE_OK != sqlite3_reset (plugin->cache_block)) 537 if (SQLITE_OK != sqlite3_reset (plugin->cache_block))
538 LOG_SQLITE (plugin, 538 LOG_SQLITE (plugin,
539 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 539 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
540 "sqlite3_reset"); 540 "sqlite3_reset");
541 return GNUNET_SYSERR; 541 return GNUNET_SYSERR;
542 542
543 } 543 }
544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
545 "Caching block under derived key `%s'\n", 545 "Caching block under derived key `%s'\n",
546 GNUNET_h2s_full (&query)); 546 GNUNET_h2s_full (&query));
547 n = sqlite3_step (plugin->cache_block); 547 n = sqlite3_step (plugin->cache_block);
548 if (SQLITE_OK != sqlite3_reset (plugin->cache_block)) 548 if (SQLITE_OK != sqlite3_reset (plugin->cache_block))
@@ -551,7 +551,7 @@ namestore_sqlite_cache_block (void *cls,
551 switch (n) 551 switch (n)
552 { 552 {
553 case SQLITE_DONE: 553 case SQLITE_DONE:
554 LOG (GNUNET_ERROR_TYPE_DEBUG, 554 LOG (GNUNET_ERROR_TYPE_DEBUG,
555 "Record stored\n"); 555 "Record stored\n");
556 return GNUNET_OK; 556 return GNUNET_OK;
557 case SQLITE_BUSY: 557 case SQLITE_BUSY:
@@ -561,7 +561,7 @@ namestore_sqlite_cache_block (void *cls,
561 default: 561 default:
562 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 562 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
563 "sqlite3_step"); 563 "sqlite3_step");
564 return GNUNET_SYSERR; 564 return GNUNET_SYSERR;
565 } 565 }
566} 566}
567 567
@@ -577,7 +577,7 @@ namestore_sqlite_cache_block (void *cls,
577 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 577 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
578 */ 578 */
579static int 579static int
580namestore_sqlite_lookup_block (void *cls, 580namestore_sqlite_lookup_block (void *cls,
581 const struct GNUNET_HashCode *query, 581 const struct GNUNET_HashCode *query,
582 GNUNET_NAMESTORE_BlockCallback iter, void *iter_cls) 582 GNUNET_NAMESTORE_BlockCallback iter, void *iter_cls)
583{ 583{
@@ -598,26 +598,26 @@ namestore_sqlite_lookup_block (void *cls,
598 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 598 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
599 "sqlite3_reset"); 599 "sqlite3_reset");
600 return GNUNET_SYSERR; 600 return GNUNET_SYSERR;
601 } 601 }
602 ret = GNUNET_NO; 602 ret = GNUNET_NO;
603 if (SQLITE_ROW == (sret = sqlite3_step (plugin->lookup_block))) 603 if (SQLITE_ROW == (sret = sqlite3_step (plugin->lookup_block)))
604 { 604 {
605 block = sqlite3_column_blob (plugin->lookup_block, 0); 605 block = sqlite3_column_blob (plugin->lookup_block, 0);
606 block_size = sqlite3_column_bytes (plugin->lookup_block, 0); 606 block_size = sqlite3_column_bytes (plugin->lookup_block, 0);
607 if ( (block_size < sizeof (struct GNUNET_NAMESTORE_Block)) || 607 if ( (block_size < sizeof (struct GNUNET_NAMESTORE_Block)) ||
608 (ntohl (block->purpose.size) + 608 (ntohl (block->purpose.size) +
609 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + 609 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) +
610 sizeof (struct GNUNET_CRYPTO_EccSignature) != block_size) ) 610 sizeof (struct GNUNET_CRYPTO_EccSignature) != block_size) )
611 { 611 {
612 GNUNET_break (0); 612 GNUNET_break (0);
613 ret = GNUNET_SYSERR; 613 ret = GNUNET_SYSERR;
614 } 614 }
615 else 615 else
616 { 616 {
617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
618 "Found block under derived key `%s'\n", 618 "Found block under derived key `%s'\n",
619 GNUNET_h2s_full (query)); 619 GNUNET_h2s_full (query));
620 iter (iter_cls, block); 620 iter (iter_cls, block);
621 ret = GNUNET_YES; 621 ret = GNUNET_YES;
622 } 622 }
623 } 623 }
@@ -625,13 +625,13 @@ namestore_sqlite_lookup_block (void *cls,
625 { 625 {
626 if (SQLITE_DONE != sret) 626 if (SQLITE_DONE != sret)
627 { 627 {
628 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step"); 628 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
629 ret = GNUNET_SYSERR; 629 ret = GNUNET_SYSERR;
630 } 630 }
631 else 631 else
632 { 632 {
633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
634 "No block found under derived key `%s'\n", 634 "No block found under derived key `%s'\n",
635 GNUNET_h2s_full (query)); 635 GNUNET_h2s_full (query));
636 } 636 }
637 } 637 }
@@ -654,8 +654,8 @@ namestore_sqlite_lookup_block (void *cls,
654 * @param rd array of records with data to store 654 * @param rd array of records with data to store
655 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 655 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
656 */ 656 */
657static int 657static int
658namestore_sqlite_store_records (void *cls, 658namestore_sqlite_store_records (void *cls,
659 const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, 659 const struct GNUNET_CRYPTO_EccPrivateKey *zone_key,
660 const char *label, 660 const char *label,
661 unsigned int rd_count, 661 unsigned int rd_count,
@@ -696,19 +696,19 @@ namestore_sqlite_store_records (void *cls,
696 } 696 }
697 697
698 /* First delete 'old' records */ 698 /* First delete 'old' records */
699 if ((SQLITE_OK != sqlite3_bind_blob (plugin->delete_records, 1, 699 if ((SQLITE_OK != sqlite3_bind_blob (plugin->delete_records, 1,
700 zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || 700 zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) ||
701 (SQLITE_OK != sqlite3_bind_text (plugin->delete_records, 2, label, -1, SQLITE_STATIC))) 701 (SQLITE_OK != sqlite3_bind_text (plugin->delete_records, 2, label, -1, SQLITE_STATIC)))
702 { 702 {
703 LOG_SQLITE (plugin, 703 LOG_SQLITE (plugin,
704 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 704 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
705 "sqlite3_bind_XXXX"); 705 "sqlite3_bind_XXXX");
706 if (SQLITE_OK != sqlite3_reset (plugin->delete_records)) 706 if (SQLITE_OK != sqlite3_reset (plugin->delete_records))
707 LOG_SQLITE (plugin, 707 LOG_SQLITE (plugin,
708 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 708 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
709 "sqlite3_reset"); 709 "sqlite3_reset");
710 return GNUNET_SYSERR; 710 return GNUNET_SYSERR;
711 711
712 } 712 }
713 n = sqlite3_step (plugin->delete_records); 713 n = sqlite3_step (plugin->delete_records);
714 if (SQLITE_OK != sqlite3_reset (plugin->delete_records)) 714 if (SQLITE_OK != sqlite3_reset (plugin->delete_records))
@@ -717,7 +717,7 @@ namestore_sqlite_store_records (void *cls,
717 717
718 if (0 != rd_count) 718 if (0 != rd_count)
719 { 719 {
720 if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1, 720 if ((SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 1,
721 zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) || 721 zone_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), SQLITE_STATIC)) ||
722 (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2, 722 (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 2,
723 &pkey_hash, sizeof (struct GNUNET_HashCode), SQLITE_STATIC)) || 723 &pkey_hash, sizeof (struct GNUNET_HashCode), SQLITE_STATIC)) ||
@@ -726,11 +726,11 @@ namestore_sqlite_store_records (void *cls,
726 (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) || 726 (SQLITE_OK != sqlite3_bind_blob (plugin->store_records, 5, data, data_size, SQLITE_STATIC)) ||
727 (SQLITE_OK != sqlite3_bind_text (plugin->store_records, 6, label, -1, SQLITE_STATIC))) 727 (SQLITE_OK != sqlite3_bind_text (plugin->store_records, 6, label, -1, SQLITE_STATIC)))
728 { 728 {
729 LOG_SQLITE (plugin, 729 LOG_SQLITE (plugin,
730 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 730 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
731 "sqlite3_bind_XXXX"); 731 "sqlite3_bind_XXXX");
732 if (SQLITE_OK != sqlite3_reset (plugin->store_records)) 732 if (SQLITE_OK != sqlite3_reset (plugin->store_records))
733 LOG_SQLITE (plugin, 733 LOG_SQLITE (plugin,
734 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 734 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
735 "sqlite3_reset"); 735 "sqlite3_reset");
736 return GNUNET_SYSERR; 736 return GNUNET_SYSERR;
@@ -756,7 +756,7 @@ namestore_sqlite_store_records (void *cls,
756 default: 756 default:
757 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 757 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
758 "sqlite3_step"); 758 "sqlite3_step");
759 return GNUNET_SYSERR; 759 return GNUNET_SYSERR;
760 } 760 }
761} 761}
762 762
@@ -775,7 +775,7 @@ namestore_sqlite_store_records (void *cls,
775 */ 775 */
776static int 776static int
777get_record_and_call_iterator (struct Plugin *plugin, 777get_record_and_call_iterator (struct Plugin *plugin,
778 sqlite3_stmt *stmt, 778 sqlite3_stmt *stmt,
779 const struct GNUNET_CRYPTO_EccPrivateKey *zone_key, 779 const struct GNUNET_CRYPTO_EccPrivateKey *zone_key,
780 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) 780 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
781{ 781{
@@ -788,7 +788,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
788 788
789 ret = GNUNET_NO; 789 ret = GNUNET_NO;
790 if (SQLITE_ROW == (sret = sqlite3_step (stmt))) 790 if (SQLITE_ROW == (sret = sqlite3_step (stmt)))
791 { 791 {
792 record_count = sqlite3_column_int (stmt, 0); 792 record_count = sqlite3_column_int (stmt, 0);
793 data_size = sqlite3_column_bytes (stmt, 1); 793 data_size = sqlite3_column_bytes (stmt, 1);
794 data = sqlite3_column_blob (stmt, 1); 794 data = sqlite3_column_blob (stmt, 1);
@@ -813,7 +813,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
813 because database might contain a large value here */ 813 because database might contain a large value here */
814 GNUNET_break (0); 814 GNUNET_break (0);
815 ret = GNUNET_SYSERR; 815 ret = GNUNET_SYSERR;
816 } 816 }
817 else 817 else
818 { 818 {
819 struct GNUNET_NAMESTORE_RecordData rd[record_count]; 819 struct GNUNET_NAMESTORE_RecordData rd[record_count];
@@ -857,8 +857,8 @@ get_record_and_call_iterator (struct Plugin *plugin,
857 * @param iter_cls closure for @a iter 857 * @param iter_cls closure for @a iter
858 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 858 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
859 */ 859 */
860static int 860static int
861namestore_sqlite_iterate_records (void *cls, 861namestore_sqlite_iterate_records (void *cls,
862 const struct GNUNET_CRYPTO_EccPrivateKey *zone, 862 const struct GNUNET_CRYPTO_EccPrivateKey *zone,
863 uint64_t offset, 863 uint64_t offset,
864 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) 864 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
@@ -876,7 +876,7 @@ namestore_sqlite_iterate_records (void *cls,
876 else 876 else
877 { 877 {
878 stmt = plugin->iterate_zone; 878 stmt = plugin->iterate_zone;
879 err = ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, 879 err = ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1,
880 zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), 880 zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
881 SQLITE_STATIC)) || 881 SQLITE_STATIC)) ||
882 (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, 882 (SQLITE_OK != sqlite3_bind_int64 (stmt, 2,
@@ -891,7 +891,7 @@ namestore_sqlite_iterate_records (void *cls,
891 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 891 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
892 "sqlite3_reset"); 892 "sqlite3_reset");
893 return GNUNET_SYSERR; 893 return GNUNET_SYSERR;
894 } 894 }
895 return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls); 895 return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls);
896} 896}
897 897
@@ -908,7 +908,7 @@ namestore_sqlite_iterate_records (void *cls,
908 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 908 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
909 */ 909 */
910static int 910static int
911namestore_sqlite_zone_to_name (void *cls, 911namestore_sqlite_zone_to_name (void *cls,
912 const struct GNUNET_CRYPTO_EccPrivateKey *zone, 912 const struct GNUNET_CRYPTO_EccPrivateKey *zone,
913 const struct GNUNET_CRYPTO_EccPublicSignKey *value_zone, 913 const struct GNUNET_CRYPTO_EccPublicSignKey *value_zone,
914 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) 914 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
@@ -917,10 +917,10 @@ namestore_sqlite_zone_to_name (void *cls,
917 sqlite3_stmt *stmt; 917 sqlite3_stmt *stmt;
918 918
919 stmt = plugin->zone_to_name; 919 stmt = plugin->zone_to_name;
920 if ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, 920 if ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1,
921 zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey), 921 zone, sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
922 SQLITE_STATIC)) || 922 SQLITE_STATIC)) ||
923 (SQLITE_OK != sqlite3_bind_blob (stmt, 2, 923 (SQLITE_OK != sqlite3_bind_blob (stmt, 2,
924 value_zone, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 924 value_zone, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
925 SQLITE_STATIC)) ) 925 SQLITE_STATIC)) )
926 { 926 {
@@ -931,7 +931,7 @@ namestore_sqlite_zone_to_name (void *cls,
931 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 931 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
932 "sqlite3_reset"); 932 "sqlite3_reset");
933 return GNUNET_SYSERR; 933 return GNUNET_SYSERR;
934 } 934 }
935 return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls); 935 return get_record_and_call_iterator (plugin, stmt, zone, iter, iter_cls);
936} 936}
937 937
@@ -952,7 +952,7 @@ libgnunet_plugin_namestore_sqlite_init (void *cls)
952 if (NULL != plugin.cfg) 952 if (NULL != plugin.cfg)
953 return NULL; /* can only initialize once! */ 953 return NULL; /* can only initialize once! */
954 memset (&plugin, 0, sizeof (struct Plugin)); 954 memset (&plugin, 0, sizeof (struct Plugin));
955 plugin.cfg = cfg; 955 plugin.cfg = cfg;
956 if (GNUNET_OK != database_setup (&plugin)) 956 if (GNUNET_OK != database_setup (&plugin))
957 { 957 {
958 database_shutdown (&plugin); 958 database_shutdown (&plugin);
@@ -965,7 +965,7 @@ libgnunet_plugin_namestore_sqlite_init (void *cls)
965 api->store_records = &namestore_sqlite_store_records; 965 api->store_records = &namestore_sqlite_store_records;
966 api->iterate_records = &namestore_sqlite_iterate_records; 966 api->iterate_records = &namestore_sqlite_iterate_records;
967 api->zone_to_name = &namestore_sqlite_zone_to_name; 967 api->zone_to_name = &namestore_sqlite_zone_to_name;
968 LOG (GNUNET_ERROR_TYPE_INFO, 968 LOG (GNUNET_ERROR_TYPE_INFO,
969 _("Sqlite database running\n")); 969 _("Sqlite database running\n"));
970 return api; 970 return api;
971} 971}
@@ -986,7 +986,7 @@ libgnunet_plugin_namestore_sqlite_done (void *cls)
986 database_shutdown (plugin); 986 database_shutdown (plugin);
987 plugin->cfg = NULL; 987 plugin->cfg = NULL;
988 GNUNET_free (api); 988 GNUNET_free (api);
989 LOG (GNUNET_ERROR_TYPE_DEBUG, 989 LOG (GNUNET_ERROR_TYPE_DEBUG,
990 "sqlite plugin is finished\n"); 990 "sqlite plugin is finished\n");
991 return NULL; 991 return NULL;
992} 992}