*/
static int
mysql_prepare (struct GNUNET_MYSQL_Context *mc,
- const char *sql,
+ const char *sql,
struct GNUNET_MYSQL_StatementHandle *stmt)
{
stmt = GNUNET_MYSQL_statement_prepare (mc,
{
LOG(GNUNET_ERROR_TYPE_ERROR,
_("Unable to initialize Mysql.\n"));
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
-
+
/*
#if DEBUG_PSYCSTORE
sqlite3_trace (plugin->dbh, &sql_trace, NULL);
");");
/* Prepare statements */
- mysql_prepare (plugin->mc,
- "BEGIN",
+ mysql_prepare (plugin->mc,
+ "BEGIN",
plugin->transaction_begin);
- mysql_prepare (plugin->mc,
- "COMMIT",
+ mysql_prepare (plugin->mc,
+ "COMMIT",
plugin->transaction_commit);
- mysql_prepare (plugin->mc,
- "ROLLBACK;",
+ mysql_prepare (plugin->mc,
+ "ROLLBACK;",
plugin->transaction_rollback);
- mysql_prepare (plugin->mc,
- "INSERT OR IGNORE INTO channels (pub_key) VALUES (?);",
+ mysql_prepare (plugin->mc,
+ "INSERT OR IGNORE INTO channels (pub_key) VALUES (?);",
plugin->insert_channel_key);
- mysql_prepare (plugin->mc,
- "INSERT OR IGNORE INTO slaves (pub_key) VALUES (?);",
+ mysql_prepare (plugin->mc,
+ "INSERT OR IGNORE INTO slaves (pub_key) VALUES (?);",
plugin->insert_slave_key);
-
- mysql_prepare (plugin->mc,
+
+ mysql_prepare (plugin->mc,
"INSERT INTO membership\n"
" (channel_id, slave_id, did_join, announced_at,\n"
" effective_since, group_generation)\n"
params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_channel", statement);
+ "mysql exec_channel", statement);
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
plugin->transaction = transaction;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql statement invalide", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_QueryParam params[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
plugin->transaction = TRANSACTION_NONE;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql statement invalide", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_QueryParam params[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
plugin->transaction = TRANSACTION_NONE;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql statement invalide", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_QueryParam params[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql statement invalide", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_QueryParam params[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
uint64_t group_generation)
{
struct Plugin *plugin = cls;
-
+
uint32_t idid_join = (uint32_t)did_join;
uint64_t iannounced_at = (uint64_t)announced_at;
uint64_t ieffective_since = (uint64_t)effective_since;
struct GNUNET_MYSQL_StatementHandle *stmt = plugin->insert_membership;
MYSQL_STMT *statement = NULL;
-/**** FAIL HERE ****/
+/**** FAIL HERE ****/
statement = GNUNET_MYSQL_statement_get_stmt (stmt);
GNUNET_assert (TRANSACTION_NONE == plugin->transaction);
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
}
struct GNUNET_MYSQL_StatementHandle *stmt = plugin->select_membership;
MYSQL_STMT *statement = NULL;
-
+
uint32_t did_join = 0;
statement = GNUNET_MYSQL_statement_get_stmt (stmt);
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql statement invalide", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
int ret = GNUNET_SYSERR;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_ResultSpec results_select[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if(0 != did_join)
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return ret;
uint32_t psycstore_flags)
{
struct Plugin *plugin = cls;
-
+
struct GNUNET_MYSQL_StatementHandle *stmt = plugin->insert_fragment;
MYSQL_STMT *statement = NULL;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
-
+
return GNUNET_OK;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
if (0 != mysql_stmt_reset (statement))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return ret;
}
+
static int
-fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt, GNUNET_PSYCSTORE_FragmentCallback cb,
+fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
+ GNUNET_PSYCSTORE_FragmentCallback cb,
void *cb_cls)
{
- int data_size = 0 ;
- uint64_t data8 = 0;
- MYSQL_STMT * statement = NULL;
- statement = GNUNET_MYSQL_statement_get_stmt (stmt);
-
- struct GNUNET_MULTICAST_MessageHeader *msg
- = GNUNET_malloc (sizeof (*msg) + data_size);
+ uint64_t fragment_id;
+ uint64_t fragment_offset;
+ uint64_t message_id;
+ uint64_t group_generation;
+ struct GNUNET_MULTICAST_MessageHeader msg; // to be removed...
+ void *buf;
+ size_t buf_size;
+ int ret;
+ uint64_t flags;
+ struct GNUNET_MULTICAST_MessageHeader *mp;
struct GNUNET_MY_ResultSpec results[] = {
- GNUNET_MY_result_spec_uint32 ((uint32_t *)&msg->hop_counter),
- GNUNET_MY_result_spec_auto_from_type (&msg->signature),
- GNUNET_MY_result_spec_auto_from_type (&msg->purpose),
- GNUNET_MY_result_spec_uint64 (&msg->fragment_id),
- GNUNET_MY_result_spec_uint64 (&msg->fragment_offset),
- GNUNET_MY_result_spec_uint64 (&msg->message_id),
- GNUNET_MY_result_spec_uint64 (&msg->group_generation),
- GNUNET_MY_result_spec_uint32 (&msg->flags),
- GNUNET_MY_result_spec_uint64 (&data8),
- GNUNET_MY_result_spec_auto_from_type (&msg[1]),
+ GNUNET_MY_result_spec_uint32 ((uint32_t *)&msg.hop_counter), // FIXME
+ GNUNET_MY_result_spec_auto_from_type (&msg.signature), // FIXME
+ GNUNET_MY_result_spec_auto_from_type (&msg.purpose), // FIXME
+ GNUNET_MY_result_spec_uint64 (&fragment_id),
+ GNUNET_MY_result_spec_uint64 (&fragment_offset),
+ GNUNET_MY_result_spec_uint64 (&message_id),
+ GNUNET_MY_result_spec_uint64 (&group_generation),
+ GNUNET_MY_result_spec_uint32 (&msg.flags), // FIXME
+ GNUNET_MY_result_spec_uint64 (&flags),
+ GNUNET_MY_result_spec_variable_size (&buf,
+ &buf_size),
GNUNET_MY_result_spec_end
};
- if (GNUNET_OK != GNUNET_MY_extract_result (stmt,
- results))
+ if (GNUNET_OK !=
+ GNUNET_MY_extract_result (stmt,
+ results))
{
- LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", statement);
+ LOG_MYSQL(plugin,
+ GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "mysql extract_result",
+ GNUNET_MYSQL_statement_get_stmt (stmt));
return GNUNET_SYSERR;
}
- return cb (cb_cls, (void *) msg, data8);
+ mp = GNUNET_malloc (sizeof (msg) + buf_size);
+ *mp = msg;
+ mp->fragment_id = GNUNET_htonll (fragment_id);
+ mp->fragment_offset = GNUNET_htonllk (fragment_offset);
+ mp->message_id = GNUNET_htonllk (message_id);
+ mp->group_generation = GNUNET_htonllk (group_generation);
+ GNUNET_memcpy (&mp[1],
+ buf,
+ buf_size);
+ ret = cb (cb_cls,
+ mp,
+ (enum GNUNET_PSYCSTORE_MessageFlags) flags);
+ GNUNET_free (mp);
+ GNUNET_MY_cleanup_result (results);
+ return ret;
}
break;
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", statement);
+ "mysql extract_result", statement);
}
}
while (sql_ret == GNUNET_YES);
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql get_stmt", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
int ret = GNUNET_SYSERR;
{
LOG_MYSQL (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return ret;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
/****** CHANGER ICI ****/
ret = fragment_row (stmt, cb, cb_cls);
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
uint64_t *max_group_generation)
{
struct Plugin *plugin = cls;
-
+
struct GNUNET_MYSQL_StatementHandle *stmt = plugin->select_counters_message;
MYSQL_STMT *statement = NULL;
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql get statement", statement);
return GNUNET_SYSERR;
- }
+ }
int ret = GNUNET_SYSERR;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql get_stmt", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
int ret = GNUNET_SYSERR;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
-
+ return GNUNET_SYSERR;
+ }
+
return GNUNET_OK;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
- }
+ return GNUNET_SYSERR;
+ }
return ret;
}
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return ret;
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql get_stmt", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
struct GNUNET_MY_QueryParam params_select[] = {
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql_stmt_reset", statement);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return ret;