* @return 0 on success
*/
static int
-sq_prepare (sqlite3 * dbh, const char *zSql, sqlite3_stmt ** ppStmt)
+sq_prepare (sqlite3 *dbh,
+ const char *zSql,
+ sqlite3_stmt **ppStmt)
{
char *dummy;
int result;
*
* @param cfg our configuration
* @param plugin the plugin context (state for this module)
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
*/
static int
database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
/**
* Shutdown database connection and associate data
* structures.
+ *
* @param plugin the plugin context (state for this module)
*/
static void
* @param rid the ID of the row to delete
*/
static int
-delete_by_rowid (struct Plugin *plugin, unsigned long long rid)
+delete_by_rowid (struct Plugin *plugin,
+ unsigned long long rid)
{
if (SQLITE_OK != sqlite3_bind_int64 (plugin->delRow, 1, rid))
{
*
* @param cls closure
* @param key key for the item
- * @param size number of bytes in data
+ * @param size number of bytes in @a data
* @param data content stored
* @param type type of the content
* @param priority priority of the content
* @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to an error message
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
*/
static int
-sqlite_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
- const void *data, enum GNUNET_BLOCK_Type type,
- uint32_t priority, uint32_t anonymity, uint32_t replication,
- struct GNUNET_TIME_Absolute expiration, char **msg)
+sqlite_plugin_put (void *cls,
+ const struct GNUNET_HashCode *key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ uint32_t replication,
+ struct GNUNET_TIME_Absolute expiration,
+ char **msg)
{
struct Plugin *plugin = cls;
int n;
* MAX of any existing expiration time and
* this value
* @param msg set to an error message
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
*/
static int
-sqlite_plugin_update (void *cls, uint64_t uid, int delta,
- struct GNUNET_TIME_Absolute expire, char **msg)
+sqlite_plugin_update (void *cls,
+ uint64_t uid,
+ int delta,
+ struct GNUNET_TIME_Absolute expire,
+ char **msg)
{
struct Plugin *plugin = cls;
int n;
* @param plugin the plugin
* @param stmt the statement
* @param proc processor to call
- * @param proc_cls closure for 'proc'
+ * @param proc_cls closure for @a proc
*/
static void
-execute_get (struct Plugin *plugin, sqlite3_stmt * stmt,
- PluginDatumProcessor proc, void *proc_cls)
+execute_get (struct Plugin *plugin,
+ sqlite3_stmt *stmt,
+ PluginDatumProcessor proc,
+ void *proc_cls)
{
int n;
struct GNUNET_TIME_Absolute expiration;
if (sqlite3_column_bytes (stmt, 4) != sizeof (struct GNUNET_HashCode))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite",
- _
- ("Invalid data in database. Trying to fix (by deletion).\n"));
+ _("Invalid data in database. Trying to fix (by deletion).\n"));
if (SQLITE_OK != sqlite3_reset (stmt))
LOG_SQLITE (plugin, NULL,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
}
-
/**
* Select a subset of the items in the datastore and call
* the given processor for the item.
* Use 0 for any type.
* @param proc function to call on each matching value;
* will be called once with a NULL value at the end
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
*/
static void
sqlite_plugin_get_zero_anonymity (void *cls, uint64_t offset,
}
-
/**
* Get results for a particular key in the datastore.
*
* Use 0 for any type.
* @param proc function to call on each matching value;
* will be called once with a NULL value at the end
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
*/
static void
-sqlite_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * key,
- const struct GNUNET_HashCode * vhash,
- enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc,
+sqlite_plugin_get_key (void *cls,
+ uint64_t offset,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_HashCode *vhash,
+ enum GNUNET_BLOCK_Type type,
+ PluginDatumProcessor proc,
void *proc_cls)
{
struct Plugin *plugin = cls;
return;
}
sqoff = 1;
- ret =
- sqlite3_bind_blob (stmt, sqoff++, key, sizeof (struct GNUNET_HashCode),
- SQLITE_TRANSIENT);
- if ((vhash != NULL) && (ret == SQLITE_OK))
- ret =
- sqlite3_bind_blob (stmt, sqoff++, vhash, sizeof (struct GNUNET_HashCode),
+ ret = sqlite3_bind_blob (stmt, sqoff++, key,
+ sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT);
+ if ((vhash != NULL) && (ret == SQLITE_OK))
+ ret = sqlite3_bind_blob (stmt, sqoff++, vhash,
+ sizeof (struct GNUNET_HashCode),
+ SQLITE_TRANSIENT);
if ((type != 0) && (ret == SQLITE_OK))
ret = sqlite3_bind_int (stmt, sqoff++, type);
if (ret == SQLITE_OK)
ret = sqlite3_bind_int64 (stmt, sqoff++, limit_off);
if (ret != SQLITE_OK)
{
- LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ LOG_SQLITE (plugin, NULL,
+ GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite_bind");
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
-
/**
- * Context for 'repl_proc' function.
+ * Context for #repl_proc() function.
*/
struct ReplCtx
{
PluginDatumProcessor proc;
/**
- * Closure for proc.
+ * Closure for @e proc.
*/
void *proc_cls;
/**
- * Wrapper for the processor for 'sqlite_plugin_replication_get'.
+ * Wrapper for the processor for #sqlite_plugin_replication_get().
* Decrements the replication counter and calls the original
* processor.
*
* @param cls closure
* @param key key for the content
- * @param size number of bytes in data
+ * @param size number of bytes in @a data
* @param data content stored
* @param type type of the content
* @param priority priority of the content
* @param expiration expiration time for the content
* @param uid unique identifier for the datum;
* maybe 0 if no unique identifier is available
- *
- * @return GNUNET_OK for normal return,
- * GNUNET_NO to delete the item
+ * @return #GNUNET_OK for normal return,
+ * #GNUNET_NO to delete the item
*/
static int
-repl_proc (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
- const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
- uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
+repl_proc (void *cls,
+ const struct GNUNET_HashCode *key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration,
uint64_t uid)
{
struct ReplCtx *rc = cls;
int ret;
- ret =
- rc->proc (rc->proc_cls, key, size, data, type, priority, anonymity,
- expiration, uid);
- if (key != NULL)
+ ret = rc->proc (rc->proc_cls,
+ key,
+ size, data,
+ type,
+ priority,
+ anonymity,
+ expiration, uid);
+ if (NULL != key)
{
rc->uid = uid;
rc->have_uid = GNUNET_YES;
* Get a random item for replication. Returns a single random item
* from those with the highest replication counters. The item's
* replication counter is decremented by one IF it was positive before.
- * Call 'proc' with all values ZERO or NULL if the datastore is empty.
+ * Call @a proc with all values ZERO or NULL if the datastore is empty.
*
* @param cls closure
* @param proc function to call the value (once only).
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
*/
static void
sqlite_plugin_get_replication (void *cls, PluginDatumProcessor proc,
}
-
/**
* Get a random item that has expired or has low priority.
- * Call 'proc' with all values ZERO or NULL if the datastore is empty.
+ * Call @a proc with all values ZERO or NULL if the datastore is empty.
*
* @param cls closure
* @param proc function to call the value (once only).
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
*/
static void
sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
}
-
/**
* Get all of the keys in the datastore.
*
* @param cls closure
* @param proc function to call on each key
- * @param proc_cls closure for proc
+ * @param proc_cls closure for @a proc
*/
static void
sqlite_plugin_get_keys (void *cls,
* Get an estimate of how much space the database is
* currently using.
*
- * @param cls the 'struct Plugin'
+ * @param cls the `struct Plugin`
* @return the size of the database on disk (estimate)
*/
static unsigned long long
/**
* Entry point for the plugin.
*
- * @param cls the "struct GNUNET_DATASTORE_PluginEnvironment*"
+ * @param cls the `struct GNUNET_DATASTORE_PluginEnvironment *`
* @return NULL on error, othrewise the plugin context
*/
void *
database_shutdown (&plugin);
return NULL;
}
- api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
+ api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions);
api->cls = &plugin;
api->estimate_size = &sqlite_plugin_estimate_size;
api->put = &sqlite_plugin_put;