- struct NextRequestClosure *nrc;
-
- nrc = GNUNET_malloc (sizeof (struct NextRequestClosure));
- nrc->plugin = plugin;
- nrc->type = type;
- nrc->iter_select = iter_select;
- nrc->dviter = dviter;
- nrc->dviter_cls = dviter_cls;
- nrc->prep = &iterator_helper_prepare;
- if (is_asc)
- {
- nrc->last_prio = 0;
- nrc->last_vkey = 0;
- nrc->last_expire = 0;
- }
- else
- {
- nrc->last_prio = 0x7FFFFFFFL;
- nrc->last_vkey = 0x7FFFFFFFFFFFFFFFLL; /* MySQL only supports 63 bits */
- nrc->last_expire = 0x7FFFFFFFFFFFFFFFLL; /* MySQL only supports 63 bits */
- }
- mysql_plugin_next_request (nrc, GNUNET_NO);
-}
-
-
-/**
- * Get an estimate of how much space the database is
- * currently using.
- *
- * @param cls our "struct Plugin *"
- * @return number of bytes used on disk
- */
-static unsigned long long
-mysql_plugin_get_size (void *cls)
-{
- struct Plugin *plugin = cls;
- MYSQL_BIND cbind[1];
- long long total;
-
- memset (cbind, 0, sizeof (cbind));
- total = 0;
- cbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
- cbind[0].buffer = &total;
- cbind[0].is_unsigned = GNUNET_NO;
- if (GNUNET_OK !=
- prepared_statement_run_select (plugin,
- plugin->get_size,
- 1, cbind,
- &return_ok, NULL,
- -1))
- return 0;
- return total;
-}
-
-
-/**
- * Store an item in the datastore.
- *
- * @param cls closure
- * @param key key for the item
- * @param size number of bytes in data
- * @param data content stored
- * @param type type of the content
- * @param priority priority of the content
- * @param anonymity anonymity-level for the content
- * @param replication replication-level for the content
- * @param expiration expiration time for the content
- * @param msg set to error message
- * @return GNUNET_OK on success
- */
-static int
-mysql_plugin_put (void *cls,
- const 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;
- unsigned int itype = type;
- unsigned int ipriority = priority;
- unsigned int ianonymity = anonymity;
- unsigned long long lexpiration = expiration.abs_value;
- unsigned long hashSize;
- unsigned long hashSize2;
- unsigned long long vkey;
- GNUNET_HashCode vhash;
-
- if (size > MAX_DATUM_SIZE)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- hashSize = sizeof (GNUNET_HashCode);
- hashSize2 = sizeof (GNUNET_HashCode);
- GNUNET_CRYPTO_hash (data, size, &vhash);
- if (GNUNET_OK != do_insert_value (plugin,
- data, size, &vkey))
- return GNUNET_SYSERR;
- if (GNUNET_OK !=
- prepared_statement_run (plugin,
- plugin->insert_entry,
- NULL,
- MYSQL_TYPE_LONG,
- &itype,
- GNUNET_YES,
- MYSQL_TYPE_LONG,
- &ipriority,
- GNUNET_YES,
- MYSQL_TYPE_LONG,
- &ianonymity,
- GNUNET_YES,
- MYSQL_TYPE_LONGLONG,
- &lexpiration,
- GNUNET_YES,
- MYSQL_TYPE_BLOB,
- key,
- hashSize,
- &hashSize,
- MYSQL_TYPE_BLOB,
- &vhash,
- hashSize2,
- &hashSize2,
- MYSQL_TYPE_LONGLONG,
- &vkey, GNUNET_YES, -1))
- {
- do_delete_value (plugin, vkey);
- return GNUNET_SYSERR;
- }
-#if DEBUG_MYSQL
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Inserted value `%s' number %llu with size %u into gn090 table\n",
- GNUNET_h2s (key),
- vkey,
- (unsigned int) size);
-#endif
- if (size > 0)
- plugin->env->duc (plugin->env->cls,
- size);
- return GNUNET_OK;
-}
-
-
-/**
- * Select a subset of the items in the datastore and call
- * the given iterator for each of them.
- *
- * @param cls our "struct Plugin*"
- * @param type entries of which type should be considered?
- * Use 0 for any type.
- * @param iter function to call on each matching value;
- * will be called once with a NULL value at the end
- * @param iter_cls closure for iter
- */
-static void
-mysql_plugin_iter_low_priority (void *cls,
- enum GNUNET_BLOCK_Type type,
- PluginIterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- iterateHelper (plugin, type, GNUNET_YES,
- 0, iter, iter_cls);
-}
-
-
-struct GetContext
-{
- GNUNET_HashCode key;
- GNUNET_HashCode vhash;