(no commit message)
[oweals/gnunet.git] / src / datastore / plugin_datastore_mysql.c
index 51a60a1dc36c77636c05bba845a5e31d7e331259..ac81c9011054d0af01bc5d73deca76c879fceedb 100644 (file)
  *
  * 1) in /etc/gnunet.conf, set
  * @verbatim
*     [datastore]
*     DATABASE = "mysql"
* @endverbatim
      [datastore]
      DATABASE = "mysql"
  @endverbatim
  * 2) Then access mysql as root,
  * @verbatim
      $ mysql -u root -p
* @endverbatim
  @endverbatim
  *    and do the following. [You should replace $USER with the username
  *    that will be running the gnunetd process].
  * @verbatim
          ON gnunet.* TO $USER@localhost;
       SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like');
       FLUSH PRIVILEGES;
* @endverbatim
  @endverbatim
  * 3) In the $HOME directory of $USER, create a ".my.cnf" file
  *    with the following lines
  * @verbatim
       [client]
       user=$USER
       password=$the_password_you_like
* @endverbatim
  @endverbatim
  *
  * Thats it. Note that .my.cnf file is a security risk unless its on
  * a safe partition etc. The $HOME/.my.cnf can of course be a symbolic
@@ -86,7 +86,7 @@
  * @verbatim
      $ mysql -u $USER -p $the_password_you_like
      mysql> use gnunet;
* @endverbatim
  @endverbatim
  *
  *    If you get the message "Database changed" it probably works.
  *
  * @verbatim
      mysql> REPAIR TABLE gn090;
      mysql> REPAIR TABLE gn072;
* @endverbatim
  @endverbatim
  *
  * PROBLEMS?
  *
  */
 
 #include "platform.h"
-#include "plugin_datastore.h"
+#include "gnunet_datastore_plugin.h"
 #include "gnunet_util_lib.h"
 #include <mysql/mysql.h>
 
@@ -663,7 +663,7 @@ init_params (struct Plugin *plugin,
   memset (qbind, 0, sizeof (qbind));
   off = 0;
   ft = 0;
-  while ((pc > 0) && (-1 != (ft = va_arg (ap, enum enum_field_types))))
+  while ((pc > 0) && (-1 != (int) (ft = va_arg (ap, enum enum_field_types))))
     {
       qbind[off].buffer_type = ft;
       switch (ft)
@@ -694,7 +694,7 @@ init_params (struct Plugin *plugin,
       pc--;
       off++;
     }
-  if (!((pc == 0) && (ft != -1) && (va_arg (ap, int) == -1)))
+  if (! ( (pc == 0) && (-1 != (int) ft) && (va_arg (ap, int) == -1) ) )
     {
       GNUNET_break (0);
       return GNUNET_SYSERR;
@@ -988,11 +988,11 @@ return_ok (void *cls,
 
 
 /**
- * FIXME.
+ * Run the prepared statement to get the next data item ready.
  * 
- * @param cls FIXME
- * @param ncr FIXME
- * @return FIXME
+ * @param cls not used
+ * @param nrc closure for the next request iterator
+ * @return GNUNET_OK on success, GNUNET_NO if there is no additional item
  */
 static int
 iterator_helper_prepare (void *cls,
@@ -1062,7 +1062,7 @@ iterator_helper_prepare (void *cls,
                                           &nrc->last_vkey,
                                           GNUNET_YES,
                                           MYSQL_TYPE_LONGLONG,
-                                          &nrc->now.value,
+                                          &nrc->now.abs_value,
                                           GNUNET_YES,
                                           MYSQL_TYPE_LONGLONG,
                                           &nrc->last_expire,
@@ -1071,7 +1071,7 @@ iterator_helper_prepare (void *cls,
                                           &nrc->last_vkey,
                                           GNUNET_YES,
                                           MYSQL_TYPE_LONGLONG,
-                                          &nrc->now.value,
+                                          &nrc->now.abs_value,
                                           GNUNET_YES, -1);
       break;
     default:
@@ -1199,7 +1199,7 @@ mysql_next_request_cont (void *next_cls,
              exp);
 #endif
   GNUNET_assert (nrc->plugin->next_task == GNUNET_SCHEDULER_NO_TASK);
-  expiration.value = exp;
+  expiration.abs_value = exp;
   ret = nrc->dviter (nrc->dviter_cls,
                     nrc,
                     &key,
@@ -1258,8 +1258,7 @@ mysql_plugin_next_request (void *next_cls,
   if (GNUNET_YES == end_it)
     nrc->end_it = GNUNET_YES;
   nrc->plugin->next_task_nc = nrc;
-  nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (nrc->plugin->env->sched,
-                                                    &mysql_next_request_cont,
+  nrc->plugin->next_task = GNUNET_SCHEDULER_add_now (&mysql_next_request_cont,
                                                     nrc);
 }  
 
@@ -1368,7 +1367,7 @@ mysql_plugin_put (void *cls,
   unsigned int itype = type;
   unsigned int ipriority = priority;
   unsigned int ianonymity = anonymity;
-  unsigned long long lexpiration = expiration.value;
+  unsigned long long lexpiration = expiration.abs_value;
   unsigned long hashSize;
   unsigned long hashSize2;
   unsigned long long vkey;
@@ -1720,7 +1719,7 @@ mysql_plugin_update (void *cls,
 {
   struct Plugin *plugin = cls;
   unsigned long long vkey = uid;
-  unsigned long long lexpire = expire.value;
+  unsigned long long lexpire = expire.abs_value;
   int ret;
 
 #if DEBUG_MYSQL
@@ -1968,8 +1967,7 @@ libgnunet_plugin_datastore_mysql_done (void *cls)
   iclose (plugin);
   if (plugin->next_task != GNUNET_SCHEDULER_NO_TASK)
     {
-      GNUNET_SCHEDULER_cancel (plugin->env->sched,
-                              plugin->next_task);
+      GNUNET_SCHEDULER_cancel (plugin->next_task);
       plugin->next_task = GNUNET_SCHEDULER_NO_TASK;
       plugin->next_task_nc->prep (plugin->next_task_nc->prep_cls, NULL);
       GNUNET_free (plugin->next_task_nc);