util \
$(JSON_DIR) \
$(REST_DIR) \
- $(JSONAPI_DIR) \
+ $(JSONAPI_DIR) \
hello \
tun \
block \
hostlist \
topology \
regex \
- cadet \
dns \
identity \
- set \
- scalarproduct \
- revocation \
gnsrecord \
namecache \
namestore \
+ peerstore \
+ cadet \
+ set \
+ scalarproduct \
+ revocation \
vpn \
gns \
$(CONVERSATION_DIR) \
- peerstore \
fs \
exit \
pt \
plugin->delete_entry_by_uid,
params_delete);
if (ret >= 0)
+ {
return GNUNET_OK;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Deleting value %llu from gn090 table failed\n", uid);
+ "Deleting value %llu from gn090 table failed\n",
+ uid);
return ret;
}
GNUNET_MY_result_spec_uint64 (&total),
GNUNET_MY_result_spec_end
};
+ int ret;
// if (GNUNET_OK ==
// GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->get_size, 1, cbind, NULL, NULL, -1))
- if (GNUNET_OK ==
- GNUNET_MY_exec_prepared (plugin->mc, plugin->get_size, params_get))
+ ret = GNUNET_MY_exec_prepared (plugin->mc, plugin->get_size, params_get);
+ if (GNUNET_OK == ret)
{
if (GNUNET_OK == GNUNET_MY_extract_result (plugin->get_size, results_get))
{
*estimate = (unsigned long long)total;
}
}
-
//*estimate = total;
else
*estimate = 0;
(unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX);
*/
- uint64_t lrvalue =
+ uint64_t lrvalue =
(uint64_t) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX);
unsigned long hashSize;
return;
}
*/
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_MY_exec_prepared (plugin->mc,
- plugin->insert_entry,
- params_insert))
+ plugin->insert_entry,
+ params_insert))
{
cont (cont_cls, key, size, GNUNET_SYSERR, _("MySQL statement run failure"));
return;
}
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Inserted value `%s' with size %u into gn090 table\n",
GNUNET_h2s (key), (unsigned int) size);
unsigned int anonymity;
// unsigned long long exp;
uint64_t exp;
- unsigned long hashSize = 0;
//size_t hashSize;
// unsigned long size;
- uint64_t size;
- unsigned long long uid = 0;
- char value[GNUNET_DATASTORE_MAX_VALUE_SIZE];
+ size_t size;
+ uint64_t uid;
+ void *value;
struct GNUNET_HashCode key;
struct GNUNET_TIME_Absolute expiration;
// MYSQL_BIND rbind[7];
GNUNET_MY_result_spec_uint32 (&anonymity),
GNUNET_MY_result_spec_uint64 (&exp),
GNUNET_MY_result_spec_auto_from_type (&key),
-// GNUNET_MY_result_spec_variable_size (&key, &hashSize),
- GNUNET_MY_result_spec_fixed_size (value, sizeof (value)),
- GNUNET_MY_result_spec_uint64 (&size),
+ GNUNET_MY_result_spec_variable_size (&value, &size),
+ GNUNET_MY_result_spec_uint64 (&uid),
GNUNET_MY_query_param_end
};
(hashSize != sizeof (struct GNUNET_HashCode)))
{
*/
- if (hashSize != sizeof (struct GNUNET_HashCode))
- {
- GNUNET_break (0);
- proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
- return;
- }
expiration.abs_value_us = exp;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n",
GNUNET_MY_query_param_fixed_size (key, hashSize),
GNUNET_MY_query_param_fixed_size (vhash, hashSize2),
GNUNET_MY_query_param_uint32 (&type),
- GNUNET_MY_query_param_end
+ GNUNET_MY_query_param_end
};
- ret =
- GNUNET_MY_exec_prepared (plugin->mc,
- plugin->count_entry_by_hash_vhash_and_type,
- params_get);
- ret =
- GNUNET_MY_extract_result (plugin->count_entry_by_hash_vhash_and_type,
- results_get);
-
+ ret =
+ GNUNET_MY_exec_prepared (plugin->mc,
+ plugin->count_entry_by_hash_vhash_and_type,
+ params_get);
+ ret =
+ GNUNET_MY_extract_result (plugin->count_entry_by_hash_vhash_and_type,
+ results_get);
}
else
{
struct GNUNET_MY_QueryParam params_get[] = {
GNUNET_MY_query_param_fixed_size (key, hashSize),
GNUNET_MY_query_param_uint32 (&type),
- GNUNET_MY_query_param_end
+ GNUNET_MY_query_param_end
};
- ret =
- GNUNET_MY_exec_prepared (plugin->mc,
- plugin->count_entry_by_hash_and_type,
- params_get);
- ret =
- GNUNET_MY_extract_result (plugin->count_entry_by_hash_vhash_and_type,
- results_get);
+ ret =
+ GNUNET_MY_exec_prepared (plugin->mc,
+ plugin->count_entry_by_hash_and_type,
+ params_get);
+ ret =
+ GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_type,
+ results_get);
}
}
else
struct GNUNET_MY_QueryParam params_get[] = {
GNUNET_MY_query_param_fixed_size (key, hashSize),
GNUNET_MY_query_param_fixed_size (vhash, hashSize2),
- GNUNET_MY_query_param_end
+ GNUNET_MY_query_param_end
};
- ret =
+ ret =
GNUNET_MY_exec_prepared (plugin->mc,
- plugin->count_entry_by_hash_and_type,
+ plugin->count_entry_by_hash_and_vhash,
params_get);
- ret =
- GNUNET_MY_extract_result (plugin->count_entry_by_hash_vhash_and_type,
+ ret =
+ GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_vhash,
results_get);
}
else
*/
struct GNUNET_MY_QueryParam params_get[] = {
GNUNET_MY_query_param_fixed_size (key, hashSize),
- GNUNET_MY_query_param_end
+ GNUNET_MY_query_param_end
};
- ret =
+ ret =
GNUNET_MY_exec_prepared (plugin->mc,
- plugin->count_entry_by_hash_and_type,
+ plugin->count_entry_by_hash,
params_get);
- ret =
- GNUNET_MY_extract_result (plugin->count_entry_by_hash_vhash_and_type,
+ ret =
+ GNUNET_MY_extract_result (plugin->count_entry_by_hash,
results_get);
}
offset = offset % total;
off = (unsigned long long) offset;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Obtaining %llu/%lld result for GET `%s'\n", off, total,
+ "Obtaining %llu/%lld result for GET `%s'\n",
+ (unsigned long long) off,
+ (unsigned long long) total,
GNUNET_h2s (key));
if (type != GNUNET_BLOCK_TYPE_ANY)
{
{
struct ReplCtx *rc = cls;
struct Plugin *plugin = rc->plugin;
- unsigned long long oid;
int ret;
int iret;
expiration, uid);
if (NULL != key)
{
- oid = (unsigned long long) uid;
- iret =
- GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->dec_repl, NULL,
- MYSQL_TYPE_LONGLONG, &oid, GNUNET_YES, -1);
-
struct GNUNET_MY_QueryParam params_proc[] = {
- GNUNET_MY_query_param_uint64 (&oid),
+ GNUNET_MY_query_param_uint64 (&uid),
GNUNET_MY_query_param_end
};
- iret =
- GNUNET_MY_exec_prepared (plugin->mc,
+ iret =
+ GNUNET_MY_exec_prepared (plugin->mc,
plugin->dec_repl,
params_proc);
if (iret == GNUNET_SYSERR)
struct ReplCtx rc;
unsigned long long rvalue;
//unsigned long repl;
- uint32_t repl;
+ uint32_t repl;
MYSQL_BIND results;
rc.plugin = plugin;
// MYSQL_BIND cbind[1];
// unsigned long length;
- statement = GNUNET_MYSQL_statement_get_stmt (plugin->mc,
- plugin->get_all_keys);
+ statement = GNUNET_MYSQL_statement_get_stmt (plugin->get_all_keys);
+
-
statements_handle_select = GNUNET_MYSQL_statement_prepare (plugin->mc,
- query);
+ query);
/*
if (statement == NULL)
{
struct GNUNET_MY_ResultSpec results_select[] = {
GNUNET_MY_result_spec_auto_from_type (&key),
- GNUNET_MY_result_spec_end
+ GNUNET_MY_result_spec_end
};
if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
mysql_stmt_error (statement));
GNUNET_MYSQL_statements_invalidate (plugin->mc);
proc (proc_cls, NULL, 0);
- return;
+ return;
}
ret = GNUNET_MY_extract_result (statements_handle_select,
#define GNUNET_MY_result_spec_auto_from_type(dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof (*(dst)))
- /**
- * Variable-size result expected
- *
- * @param[out] dst where to store the result, allocated
- * @param[out] sptr where to store the size of @a dst
- * @return array entru for the result specification to use
- */
+/**
+ * Variable-size result expected
+ *
+ * @param[out] dst where to store the result, allocated
+ * @param[out] sptr where to store the size of @a dst
+ * @return array entru for the result specification to use
+ */
struct GNUNET_MY_ResultSpec
GNUNET_MY_result_spec_variable_size (void **dst,
- size_t *ptr_size);
+ size_t *ptr_size);
+
/**
- * RSA public key expected
- *
- * @param name name of the field in the table
- * @param[out] rsa where to store the result
- * @return array entry for the result specification to use
- */
+ * RSA public key expected
+ *
+ * @param name name of the field in the table
+ * @param[out] rsa where to store the result
+ * @return array entry for the result specification to use
+ */
struct GNUNET_MY_ResultSpec
GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa);
+
/**
- * RSA signature expected.
- *
- * @param[out] sig where to store the result;
- * @return array entry for the result specification to use
- */
+ * RSA signature expected.
+ *
+ * @param[out] sig where to store the result;
+ * @return array entry for the result specification to use
+ */
struct GNUNET_MY_ResultSpec
GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig);
* be used, and if, with caution! On failures during the interaction with
* the handle, you must call 'GNUNET_MYSQL_statements_invalidate'!
*
- * @param mc mysql context
* @param sh prepared statement to introspect
* @return MySQL statement handle, NULL on error
*/
MYSQL_STMT *
-GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh);
+GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh);
/**
/**
* Run a prepared SELECT statement.
*
- * @param mc mysql context
* @param sh handle to SELECT statment
* @param result_size number of elements in results array
* @param results pointer to already initialized MYSQL_BIND
* the number of successfully affected (or queried) rows
*/
int
-GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh,
+GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_StatementHandle *sh,
unsigned int result_size, MYSQL_BIND * results,
GNUNET_MYSQL_DataProcessor processor,
void *processor_cls, ...);
/**
* Run a prepared SELECT statement.
*
- * @param mc mysql context
* @param s statement to run
* @param result_size number of elements in results array
* @param results pointer to already initialized MYSQL_BIND
* the number of successfully affected (or queried) rows
*/
int
-GNUNET_MYSQL_statement_run_prepared_select_va (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *s,
+GNUNET_MYSQL_statement_run_prepared_select_va (struct GNUNET_MYSQL_StatementHandle *s,
unsigned int result_size,
MYSQL_BIND * results,
GNUNET_MYSQL_DataProcessor processor,
/**
* Run a prepared statement that does NOT produce results.
*
- * @param mc mysql context
* @param sh handle to statment
* @param insert_id NULL or address where to store the row ID of whatever
* was inserted (only for INSERT statements!)
* the number of successfully affected rows
*/
int
-GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh,
+GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_StatementHandle *sh,
unsigned long long *insert_id, ...);
MYSQL_BIND qbind[num];
unsigned int off;
- memset(qbind, 0, sizeof(qbind));
+ memset (qbind, 0, sizeof(qbind));
off = 0;
for (i=0;NULL != (p = ¶ms[i])->conv;i++)
{
}
off += p->num_params;
}
- stmt = GNUNET_MYSQL_statement_get_stmt (mc, sh);
+ stmt = GNUNET_MYSQL_statement_get_stmt (sh);
if (mysql_stmt_bind_param (stmt,
qbind))
{
int ret;
MYSQL_STMT *stmt;
- stmt = GNUNET_MYSQL_statement_get_stmt (NULL, sh);
+ stmt = GNUNET_MYSQL_statement_get_stmt (sh);
if (NULL == stmt)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql",
__FILE__, __LINE__,
mysql_stmt_error (stmt));
GNUNET_MY_cleanup_result (rs);
+ mysql_stmt_free_result (stmt);
return GNUNET_SYSERR;
}
field_off = 0;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Post-conversion for MySQL result failed at offset %u\n",
i);
+ mysql_stmt_free_result (stmt);
GNUNET_MY_cleanup_result (rs);
return GNUNET_SYSERR;
}
field_off += rp->num_fields;
}
}
+ mysql_stmt_free_result (stmt);
return GNUNET_OK;
}
*/
struct GNUNET_MYSQL_StatementHandle *prev;
+ /**
+ * Mysql Context the statement handle belongs to.
+ */
+ struct GNUNET_MYSQL_Context *mc;
+
/**
* Original query string.
*/
struct GNUNET_MYSQL_StatementHandle *sh;
sh = GNUNET_new (struct GNUNET_MYSQL_StatementHandle);
+ sh->mc = mc;
sh->query = GNUNET_strdup (query);
GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh);
return sh;
* @return GNUNET_OK on success
*/
static int
-prepare_statement (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh)
+prepare_statement (struct GNUNET_MYSQL_StatementHandle *sh)
{
+ struct GNUNET_MYSQL_Context *mc = sh->mc;
+
if (GNUNET_YES == sh->valid)
return GNUNET_OK;
if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc)))
* be used, and if, with caution! On failures during the interaction with
* the handle, you must call 'GNUNET_MYSQL_statements_invalidate'!
*
- * @param mc mysql context
* @param sh prepared statement to introspect
* @return MySQL statement handle, NULL on error
*/
MYSQL_STMT *
-GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_Context * mc,
- struct GNUNET_MYSQL_StatementHandle * sh)
+GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh)
{
- (void) prepare_statement (mc, sh);
+ (void) prepare_statement (sh);
return sh->statement;
}
* Bind the parameters for the given MySQL statement
* and run it.
*
- * @param mc mysql context
* @param sh statement to bind and run
* @param ap arguments for the binding
* @return GNUNET_SYSERR on error, GNUNET_OK on success
*/
static int
-init_params (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh, va_list ap)
+init_params (struct GNUNET_MYSQL_StatementHandle *sh, va_list ap)
{
+ struct GNUNET_MYSQL_Context *mc = sh->mc;
MYSQL_BIND qbind[MAX_PARAM];
unsigned int pc;
unsigned int off;
/**
* Run a prepared SELECT statement.
*
- * @param mc mysql context
* @param s statement to run
* @param result_size number of elements in results array
* @param results pointer to already initialized MYSQL_BIND
* the number of successfully affected (or queried) rows
*/
int
-GNUNET_MYSQL_statement_run_prepared_select_va (struct GNUNET_MYSQL_Context *mc,
- struct
+GNUNET_MYSQL_statement_run_prepared_select_va (struct
GNUNET_MYSQL_StatementHandle *s,
unsigned int result_size,
MYSQL_BIND * results,
unsigned int rsize;
int total;
- if (GNUNET_OK != prepare_statement (mc, s))
+ if (GNUNET_OK != prepare_statement (s))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK != init_params (mc, s, ap))
+ if (GNUNET_OK != init_params (s, ap))
{
GNUNET_break (0);
return GNUNET_SYSERR;
_("`%s' failed at %s:%d with error: %s\n"),
"mysql_stmt_bind_result", __FILE__, __LINE__,
mysql_stmt_error (s->statement));
- GNUNET_MYSQL_statements_invalidate (mc);
+ GNUNET_MYSQL_statements_invalidate (s->mc);
return GNUNET_SYSERR;
}
_("`%s' failed at %s:%d with error: %s\n"),
"mysql_stmt_fetch", __FILE__, __LINE__,
mysql_stmt_error (s->statement));
- GNUNET_MYSQL_statements_invalidate (mc);
+ GNUNET_MYSQL_statements_invalidate (s->mc);
return GNUNET_SYSERR;
}
total++;
/**
* Run a prepared SELECT statement.
*
- * @param mc mysql context
* @param sh handle to SELECT statment
* @param result_size number of elements in results array
* @param results pointer to already initialized MYSQL_BIND
* the number of successfully affected (or queried) rows
*/
int
-GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle
+GNUNET_MYSQL_statement_run_prepared_select (struct GNUNET_MYSQL_StatementHandle
*sh, unsigned int result_size,
MYSQL_BIND * results,
GNUNET_MYSQL_DataProcessor
va_start (ap, processor_cls);
ret =
- GNUNET_MYSQL_statement_run_prepared_select_va (mc, sh, result_size,
+ GNUNET_MYSQL_statement_run_prepared_select_va (sh, result_size,
results, processor,
processor_cls, ap);
va_end (ap);
/**
* Run a prepared statement that does NOT produce results.
*
- * @param mc mysql context
* @param sh handle to statment
* @param insert_id NULL or address where to store the row ID of whatever
* was inserted (only for INSERT statements!)
* the number of successfully affected rows
*/
int
-GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_Context *mc,
- struct GNUNET_MYSQL_StatementHandle *sh,
+GNUNET_MYSQL_statement_run_prepared (struct GNUNET_MYSQL_StatementHandle *sh,
unsigned long long *insert_id, ...)
{
va_list ap;
int affected;
- if (GNUNET_OK != prepare_statement (mc, sh))
+ if (GNUNET_OK != prepare_statement (sh))
return GNUNET_SYSERR;
va_start (ap, insert_id);
- if (GNUNET_OK != init_params (mc, sh, ap))
+ if (GNUNET_OK != init_params (sh, ap))
{
va_end (ap);
return GNUNET_SYSERR;