fix bad free
[oweals/gnunet.git] / src / include / gnunet_psycstore_plugin.h
index 5d5014fb37789df69811371710e68984fcce4fe8..276d60638639ed6c98761b77daed8e9ac08c3a04 100644 (file)
@@ -1,27 +1,30 @@
 /*
      This file is part of GNUnet
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /**
- * @file include/gnunet_psycstore_plugin.h
- * @brief plugin API for the PSYCstore database backend
  * @author Gabor X Toth
+ *
+ * @file
+ * Plugin API for the PSYCstore database backend
+ *
+ * @defgroup psycstore-plugin  PSYC Store plugin API
+ * Plugin API for the PSYC Store database backend
+ * @{
  */
 #ifndef GNUNET_PSYCSTORE_PLUGIN_H
 #define GNUNET_PSYCSTORE_PLUGIN_H
@@ -49,7 +52,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   void *cls;
 
-  /** 
+  /**
    * Store join/leave events for a PSYC channel in order to be able to answer
    * membership test queries later.
    *
@@ -59,14 +62,14 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*membership_store) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                       const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
                        int did_join,
                        uint64_t announced_at,
                        uint64_t effective_since,
                        uint64_t group_generation);
 
-  /** 
+  /**
    * Test if a member was admitted to the channel at the given message ID.
    *
    * @see GNUNET_PSYCSTORE_membership_test()
@@ -76,11 +79,11 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*membership_test) (void *cls,
-                      const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                      const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key,
+                      const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                      const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
                       uint64_t message_id);
 
-  /** 
+  /**
    * Store a message fragment sent to a channel.
    *
    * @see GNUNET_PSYCSTORE_fragment_store()
@@ -89,11 +92,11 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*fragment_store) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                      const struct GNUNET_MULTICAST_MessageHeader *message,
                      uint32_t psycstore_flags);
 
-  /** 
+  /**
    * Set additional flags for a given message.
    *
    * They are OR'd with any existing flags set.
@@ -107,12 +110,12 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_add_flags) (void *cls,
-                        const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                        const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                         uint64_t message_id,
-                        uint64_t psycstore_flags);
+                        uint32_t psycstore_flags);
 
-  /** 
-   * Retrieve a message fragment by fragment ID.
+  /**
+   * Retrieve a message fragment range by fragment ID.
    *
    * @see GNUNET_PSYCSTORE_fragment_get()
    *
@@ -120,13 +123,30 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*fragment_get) (void *cls,
-                   const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                   uint64_t fragment_id,
+                   const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                   uint64_t first_fragment_id,
+                   uint64_t last_fragment_id,
+                   uint64_t *returned_fragments,
                    GNUNET_PSYCSTORE_FragmentCallback cb,
                    void *cb_cls);
 
-  /** 
-   * Retrieve all fragments of a message.
+  /**
+   * Retrieve latest message fragments.
+   *
+   * @see GNUNET_PSYCSTORE_fragment_get()
+   *
+   * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+   */
+  int
+  (*fragment_get_latest) (void *cls,
+                          const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                          uint64_t fragment_limit,
+                          uint64_t *returned_fragments,
+                          GNUNET_PSYCSTORE_FragmentCallback cb,
+                          void *cb_cls);
+
+  /**
+   * Retrieve all fragments of a message ID range.
    *
    * @see GNUNET_PSYCSTORE_message_get()
    *
@@ -134,13 +154,30 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_get) (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                  uint64_t message_id,
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                  uint64_t first_fragment_id,
+                  uint64_t last_fragment_id,
+                  uint64_t fragment_limit,
                   uint64_t *returned_fragments,
                   GNUNET_PSYCSTORE_FragmentCallback cb,
                   void *cb_cls);
 
-  /** 
+  /**
+   * Retrieve all fragments of the latest messages.
+   *
+   * @see GNUNET_PSYCSTORE_message_get()
+   *
+   * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+   */
+  int
+  (*message_get_latest) (void *cls,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                         uint64_t fragment_limit,
+                         uint64_t *returned_fragments,
+                         GNUNET_PSYCSTORE_FragmentCallback cb,
+                         void *cb_cls);
+
+  /**
    * Retrieve a fragment of message specified by its message ID and fragment
    * offset.
    *
@@ -150,13 +187,13 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*message_get_fragment) (void *cls,
-                           const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                           const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                            uint64_t message_id,
                            uint64_t fragment_offset,
                            GNUNET_PSYCSTORE_FragmentCallback cb,
                            void *cb_cls);
 
-  /** 
+  /**
    * Retrieve the max. values of message counters for a channel.
    *
    * @see GNUNET_PSYCSTORE_counters_get()
@@ -165,12 +202,12 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*counters_message_get) (void *cls,
-                           const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                           const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                            uint64_t *max_fragment_id,
                            uint64_t *max_message_id,
                            uint64_t *max_group_generation);
 
-  /** 
+  /**
    * Retrieve the max. values of state counters for a channel.
    *
    * @see GNUNET_PSYCSTORE_counters_get()
@@ -179,11 +216,11 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*counters_state_get) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                          uint64_t *max_state_message_id);
 
 
-  /** 
+  /**
    * Begin modifying current state.
    *
    * @see GNUNET_PSYCSTORE_state_modify()
@@ -192,10 +229,10 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_modify_begin) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                          uint64_t message_id, uint64_t state_delta);
 
-  /** 
+  /**
    * Set the current value of a state variable.
    *
    * The state modification process is started with state_modify_begin(),
@@ -207,12 +244,13 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
    */
   int
-  (*state_modify_set) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                       const char *name, const void *value, size_t value_size);
+  (*state_modify_op) (void *cls,
+                      const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                      enum GNUNET_PSYC_Operator op,
+                      const char *name, const void *value, size_t value_size);
 
 
-  /** 
+  /**
    * End modifying current state.
    *
    * @see GNUNET_PSYCSTORE_state_modify()
@@ -221,11 +259,11 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_modify_end) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        uint64_t message_id);
 
 
-  /** 
+  /**
    * Begin synchronizing state.
    *
    * @see GNUNET_PSYCSTORE_state_sync()
@@ -234,26 +272,26 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_sync_begin) (void *cls,
-                         const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                         const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
-  /** 
-   * Set the value of a state variable while synchronizing state.
+  /**
+   * Assign value of a state variable while synchronizing state.
    *
    * The state synchronization process is started with state_sync_begin(),
    * which is followed by one or more calls to this function,
-   * and finished with state_sync_end().
+   * and finished using state_sync_end().
    *
    * @see GNUNET_PSYCSTORE_state_sync()
    *
    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
    */
   int
-  (*state_sync_set) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                     const char *name, const void *value, size_t value_size);
+  (*state_sync_assign) (void *cls,
+                        const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                        const char *name, const void *value, size_t value_size);
 
 
-  /** 
+  /**
    * End synchronizing state.
    *
    * @see GNUNET_PSYCSTORE_state_sync()
@@ -262,11 +300,12 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_sync_end) (void *cls,
-                     const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
-                     uint64_t message_id);
+                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
+                     uint64_t max_state_message_id,
+                     uint64_t state_hash_message_id);
 
 
-  /** 
+  /**
    * Reset the state of a channel.
    *
    * Delete all state variables stored for the given channel.
@@ -277,7 +316,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_reset) (void *cls,
-                  const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
   /**
    * Update signed state values from the current ones.
@@ -286,22 +325,22 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_update_signed) (void *cls,
-                          const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key);
+                          const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key);
 
 
-  /** 
+  /**
    * Retrieve a state variable by name (exact match).
    *
    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
    */
   int
   (*state_get) (void *cls,
-                const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                 const char *name,
                 GNUNET_PSYCSTORE_StateCallback cb,
                 void *cb_cls);
 
-  /** 
+  /**
    * Retrieve all state variables for a channel with the given prefix.
    *
    * @see GNUNET_PSYCSTORE_state_get_prefix()
@@ -310,20 +349,20 @@ struct GNUNET_PSYCSTORE_PluginFunctions
    */
   int
   (*state_get_prefix) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        const char *name,
                        GNUNET_PSYCSTORE_StateCallback cb,
                        void *cb_cls);
 
 
-  /** 
+  /**
    * Retrieve all signed state variables for a channel.
    *
    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
    */
   int
   (*state_get_signed) (void *cls,
-                       const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key,
+                       const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                        GNUNET_PSYCSTORE_StateCallback cb,
                        void *cb_cls);
 
@@ -337,5 +376,6 @@ struct GNUNET_PSYCSTORE_PluginFunctions
 }
 #endif
 
-/* end of gnunet_psycstore_plugin.h */
 #endif
+
+/** @} */  /* end of group */