-static int
-namestore_sqlite_put_record (void *cls,
- const GNUNET_HashCode *zone,
- const char *name,
- uint32_t record_type,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- struct GNUNET_TIME_Absolute expiration,
- enum GNUNET_NAMESTORE_RecordFlags flags,
- size_t data_size,
- const void *data)
-{
- struct Plugin *plugin = cls;
- int n;
- GNUNET_HashCode nh;
- size_t name_len;
-
- name_len = strlen (name);
- GNUNET_CRYPTO_hash (name, name_len, &nh);
- if ((SQLITE_OK != sqlite3_bind_blob (plugin->put_record, 1, zone, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->put_record, 2, loc->revision)) ||
- (SQLITE_OK != sqlite3_bind_blob (plugin->put_record, 3, &nh, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_text (plugin->put_record, 4, name, -1, SQLITE_STATIC)) ||
- (SQLITE_OK != sqlite3_bind_int (plugin->put_record, 5, record_type)) ||
- (SQLITE_OK != sqlite3_bind_int (plugin->put_record, 6, loc->depth)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->put_record, 7, loc->offset)) ||
- (SQLITE_OK != sqlite3_bind_int64 (plugin->put_record, 8, expiration.abs_value)) ||
- (SQLITE_OK != sqlite3_bind_int (plugin->put_record, 9, flags)) ||
- (SQLITE_OK != sqlite3_bind_blob (plugin->put_record, 10, data, data_size, SQLITE_STATIC)) )
- {
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (plugin->put_record))
- LOG_SQLITE (plugin,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
- return GNUNET_SYSERR;
-
- }
- n = sqlite3_step (plugin->put_record);
- if (SQLITE_OK != sqlite3_reset (plugin->put_record))
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_reset");
- switch (n)
- {
- case SQLITE_DONE:
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Record stored\n");
- return GNUNET_OK;
- case SQLITE_BUSY:
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
- return GNUNET_NO;
- default:
- LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
- return GNUNET_SYSERR;
- }
-}
-
-
-/**
- * Store a Merkle tree node in the datastore.
- *
- * @param cls closure (internal context for the plugin)
- * @param zone hash of public key of the zone
- * @param loc location in the B-tree
- * @param ploc parent's location in the B-tree (must have depth = loc.depth + 1), NULL for root
- * @param num_entries number of entries at this node in the B-tree
- * @param entries the 'num_entries' entries to store (hashes over the
- * records)
- * @return GNUNET_OK on success
- */
-static int
-namestore_sqlite_put_node (void *cls,
- const GNUNET_HashCode *zone,
- const struct GNUNET_NAMESTORE_SignatureLocation *loc,
- const struct GNUNET_NAMESTORE_SignatureLocation *ploc,
- unsigned int num_entries,
- const GNUNET_HashCode *entries)