summaryrefslogtreecommitdiff
path: root/src/namestore/plugin_namestore_sqlite.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-29 11:11:10 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-29 11:11:10 +0000
commita74f95cb209906901dc44cff013fa9200c4e2e4e (patch)
treeb07c642e8a9d0345d2f7fcbf46834d9cba25b7ed /src/namestore/plugin_namestore_sqlite.c
parentfd9ed7b5a3e296ad99e39c36d011d5a9db6f46dd (diff)
downloadgnunet-a74f95cb209906901dc44cff013fa9200c4e2e4e.tar.gz
gnunet-a74f95cb209906901dc44cff013fa9200c4e2e4e.zip
nametore api change
Diffstat (limited to 'src/namestore/plugin_namestore_sqlite.c')
-rw-r--r--src/namestore/plugin_namestore_sqlite.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index c29721643..0e0fc5243 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -490,6 +490,7 @@ namestore_sqlite_put_records (void *cls,
490 (void) namestore_sqlite_remove_records (plugin, &zone, name); 490 (void) namestore_sqlite_remove_records (plugin, &zone, name);
491 name_len = strlen (name); 491 name_len = strlen (name);
492 GNUNET_CRYPTO_hash (name, name_len, &nh); 492 GNUNET_CRYPTO_hash (name, name_len, &nh);
493
493 rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 494 rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
494 data_size = rd_count * sizeof (struct DbRecord); 495 data_size = rd_count * sizeof (struct DbRecord);
495 for (i=0;i<rd_count;i++) 496 for (i=0;i<rd_count;i++)
@@ -564,7 +565,7 @@ namestore_sqlite_put_records (void *cls,
564 * 565 *
565 * @param cls closure (internal context for the plugin) 566 * @param cls closure (internal context for the plugin)
566 * @param zone hash of public key of the zone, NULL to iterate over all zones 567 * @param zone hash of public key of the zone, NULL to iterate over all zones
567 * @param name_hash hash of name, NULL to iterate over all records of the zone 568 * @param name name as string, NULL to iterate over all records of the zone
568 * @param offset offset in the list of all matching records 569 * @param offset offset in the list of all matching records
569 * @param iter function to call with the result 570 * @param iter function to call with the result
570 * @param iter_cls closure for iter 571 * @param iter_cls closure for iter
@@ -573,26 +574,33 @@ namestore_sqlite_put_records (void *cls,
573static int 574static int
574namestore_sqlite_iterate_records (void *cls, 575namestore_sqlite_iterate_records (void *cls,
575 const GNUNET_HashCode *zone, 576 const GNUNET_HashCode *zone,
576 const GNUNET_HashCode *name_hash, 577 const char *name,
577 uint64_t offset, 578 uint64_t offset,
578 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls) 579 GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
579{ 580{
580 struct Plugin *plugin = cls; 581 struct Plugin *plugin = cls;
581 sqlite3_stmt *stmt; 582 sqlite3_stmt *stmt;
583 GNUNET_HashCode name_hase;
582 unsigned int boff; 584 unsigned int boff;
583 int ret; 585 int ret;
584 int sret; 586 int sret;
585 587
586 if (NULL == zone) 588 if (NULL == zone)
587 if (NULL == name_hash) 589 if (NULL == name)
588 stmt = plugin->iterate_all; 590 stmt = plugin->iterate_all;
589 else 591 else
592 {
593 GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
590 stmt = plugin->iterate_by_name; 594 stmt = plugin->iterate_by_name;
595 }
591 else 596 else
592 if (NULL == name_hash) 597 if (NULL == name)
593 stmt = plugin->iterate_by_zone; 598 stmt = plugin->iterate_by_zone;
594 else 599 else
600 {
601 GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
595 stmt = plugin->iterate_records; 602 stmt = plugin->iterate_records;
603 }
596 604
597 boff = 0; 605 boff = 0;
598 if ( (NULL != zone) && 606 if ( (NULL != zone) &&
@@ -608,11 +616,12 @@ namestore_sqlite_iterate_records (void *cls,
608 "sqlite3_reset"); 616 "sqlite3_reset");
609 return GNUNET_SYSERR; 617 return GNUNET_SYSERR;
610 } 618 }
611 if ( (NULL != name_hash) && 619 if ( (NULL != name) &&
612 (SQLITE_OK != sqlite3_bind_blob (stmt, ++boff, 620 (SQLITE_OK != sqlite3_bind_blob (stmt, ++boff,
613 name_hash, sizeof (GNUNET_HashCode), 621 &name_hase, sizeof (GNUNET_HashCode),
614 SQLITE_STATIC)) ) 622 SQLITE_STATIC)) )
615 { 623 {
624 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ITERATE NAME HASH: `%s'", GNUNET_h2s_full(&name_hase));
616 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 625 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
617 "sqlite3_bind_XXXX"); 626 "sqlite3_bind_XXXX");
618 if (SQLITE_OK != sqlite3_reset (stmt)) 627 if (SQLITE_OK != sqlite3_reset (stmt))