fix bad free
[oweals/gnunet.git] / src / include / gnunet_psycstore_service.h
index 99f27a994d0f86d10e556430b437f9931b3ccf6d..7d52259f095c45c710477f5163320b8c1108bb76 100644 (file)
@@ -1,28 +1,31 @@
 /*
      This file is part of GNUnet.
-     Copyright (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., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, 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_service.h
- * @brief PSYCstore service; implements persistent storage for the PSYC service
  * @author Gabor X Toth
  * @author Christian Grothoff
+ *
+ * @file
+ * PSYCstore service; implements persistent storage for the PSYC service
+ *
+ * @defgroup psycstore  PSYC Store service
+ * Persistent storage for the PSYC service.
+ * @{
  */
 #ifndef GNUNET_PSYCSTORE_SERVICE_H
 #define GNUNET_PSYCSTORE_SERVICE_H
@@ -36,7 +39,7 @@ extern "C"
 #endif
 
 #include "gnunet_util_lib.h"
-#include "gnunet_env_lib.h"
+#include "gnunet_psyc_util_lib.h"
 #include "gnunet_multicast_service.h"
 #include "gnunet_psyc_service.h"
 
@@ -144,9 +147,9 @@ typedef void
  *        In case of a part, the last group generation the slave has access to.
  *        It has relevance when a larger message have fragments with different
  *        group generations.
- * @param rcb
+ * @param result_cb
  *        Callback to call with the result of the storage operation.
- * @param rcb_cls
+ * @param cls
  *        Closure for the callback.
  *
  * @return Operation handle that can be used to cancel the operation.
@@ -159,8 +162,8 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
                                    uint64_t announced_at,
                                    uint64_t effective_since,
                                    uint64_t group_generation,
-                                   GNUNET_PSYCSTORE_ResultCallback rcb,
-                                   void *rcb_cls);
+                                   GNUNET_PSYCSTORE_ResultCallback result_cb,
+                                   void *cls);
 
 
 /**
@@ -183,9 +186,9 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
  *        Group generation of the fragment of the message to test.
  *        It has relevance if the message consists of multiple fragments with
  *        different group generations.
- * @param rcb
+ * @param result_cb
  *        Callback to call with the test result.
- * @param rcb_cls
+ * @param cls
  *        Closure for the callback.
  *
  * @return Operation handle that can be used to cancel the operation.
@@ -196,8 +199,8 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
                                   const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
                                   uint64_t message_id,
                                   uint64_t group_generation,
-                                  GNUNET_PSYCSTORE_ResultCallback rcb,
-                                  void *rcb_cls);
+                                  GNUNET_PSYCSTORE_ResultCallback result_cb,
+                                  void *cls);
 
 
 /**
@@ -208,8 +211,8 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
  * @param msg Message to store.
  * @param psycstore_flags Flags indicating whether the PSYC message contains
  *        state modifiers.
- * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the callback.
+ * @param result_cb Callback to call with the result of the operation.
+ * @param cls Closure for the callback.
  *
  * @return Handle that can be used to cancel the operation.
  */
@@ -218,8 +221,8 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
                                  const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                  const struct GNUNET_MULTICAST_MessageHeader *msg,
                                  enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags,
-                                 GNUNET_PSYCSTORE_ResultCallback rcb,
-                                 void *rcb_cls);
+                                 GNUNET_PSYCSTORE_ResultCallback result_cb,
+                                 void *cls);
 
 
 /**
@@ -298,7 +301,7 @@ GNUNET_PSYCSTORE_fragment_get (struct GNUNET_PSYCSTORE_Handle *h,
  *        Maximum number of fragments to retrieve.
  * @param fragment_cb
  *        Callback to call with the retrieved fragments.
- * @param rcb
+ * @param result_cb
  *        Callback to call with the result of the operation.
  * @param cls
  *        Closure for the callbacks.
@@ -311,7 +314,7 @@ GNUNET_PSYCSTORE_fragment_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
                                       const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
                                       uint64_t fragment_limit,
                                       GNUNET_PSYCSTORE_FragmentCallback fragment_cb,
-                                      GNUNET_PSYCSTORE_ResultCallback rcb,
+                                      GNUNET_PSYCSTORE_ResultCallback result_cb,
                                       void *cls);
 
 
@@ -330,6 +333,8 @@ GNUNET_PSYCSTORE_fragment_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
  *        First message ID to retrieve.
  * @param last_message_id
  *        Last consecutive message ID to retrieve.
+ * @param fragment_limit
+ *        Maximum number of fragments to retrieve.
  * @param method_prefix
  *        Retrieve only messages with a matching method prefix.
  * @param fragment_cb
@@ -347,6 +352,7 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
                               const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key,
                               uint64_t first_message_id,
                               uint64_t last_message_id,
+                              uint64_t fragment_limit,
                               const char *method_prefix,
                               GNUNET_PSYCSTORE_FragmentCallback fragment_cb,
                               GNUNET_PSYCSTORE_ResultCallback result_cb,
@@ -384,7 +390,7 @@ GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
                                      uint64_t message_limit,
                                      const char *method_prefix,
                                      GNUNET_PSYCSTORE_FragmentCallback fragment_cb,
-                                     GNUNET_PSYCSTORE_ResultCallback rcb,
+                                     GNUNET_PSYCSTORE_ResultCallback result_cb,
                                      void *cls);
 
 
@@ -430,14 +436,19 @@ GNUNET_PSYCSTORE_message_get_fragment (struct GNUNET_PSYCSTORE_Handle *h,
  * @see GNUNET_PSYCSTORE_counters_get()
  *
  * @param cls Closure.
- * @param result_code Status code for the operation:
+ * @param result_code
+ *        Status code for the operation:
  *        #GNUNET_OK: success, counter values are returned.
  *        #GNUNET_NO: no message has been sent to the channel yet.
  *        #GNUNET_SYSERR: an error occurred.
- * @param max_fragment_id Latest message fragment ID, used by multicast.
- * @param max_message_id Latest message ID, used by PSYC.
- * @param max_group_generation Latest group generation, used by PSYC.
- * @param max_state_message_id Latest message ID containing state modifiers that
+ * @param max_fragment_id
+ *        Latest message fragment ID, used by multicast.
+ * @param max_message_id
+ *        Latest message ID, used by PSYC.
+ * @param max_group_generation
+ *        Latest group generation, used by PSYC.
+ * @param max_state_message_id
+ *        Latest message ID containing state modifiers that
  *        was applied to the state store.  Used for the state sync process.
  */
 typedef void
@@ -457,18 +468,22 @@ typedef void
  *   the counters from their last value.
  * - when a channel slave rejoins and starts the state synchronization process.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key Public key that identifies the channel.
- * @param ccb Callback to call with the result.
- * @param ccb_cls Closure for the @a ccb callback.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        Public key that identifies the channel.
+ * @param counters_cb
+ *        Callback to call with the result.
+ * @param cls
+ *        Closure for the @a ccb callback.
  *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h,
                                struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
-                               GNUNET_PSYCSTORE_CountersCallback ccb,
-                               void *ccb_cls);
+                               GNUNET_PSYCSTORE_CountersCallback counters_cb,
+                               void *cls);
 
 
 /**
@@ -477,14 +492,18 @@ GNUNET_PSYCSTORE_counters_get (struct GNUNET_PSYCSTORE_Handle *h,
  * An error is returned if there are missing messages containing state
  * operations before the current one.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param message_id ID of the message that contains the @a modifiers.
- * @param state_delta Value of the @e state_delta PSYC header variable of the message.
- * @param modifier_count Number of elements in the @a modifiers array.
- * @param modifiers List of modifiers to apply.
- * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the @a rcb callback.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param message_id
+ *        ID of the message that contains the @a modifiers.
+ * @param state_delta
+ *        Value of the @e state_delta PSYC header variable of the message.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the @a result_cb callback.
  *
  * @return Handle that can be used to cancel the operation.
  */
@@ -493,33 +512,41 @@ GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
                                const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                uint64_t message_id,
                                uint64_t state_delta,
-                               size_t modifier_count,
-                               const struct GNUNET_ENV_Modifier *modifiers,
-                               GNUNET_PSYCSTORE_ResultCallback rcb,
-                               void *rcb_cls);
+                               GNUNET_PSYCSTORE_ResultCallback result_cb,
+                               void *cls);
 
 
 /**
  * Store synchronized state.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param message_id ID of the message that contains the state_hash PSYC header variable.
- * @param modifier_count Number of elements in the @a modifiers array.
- * @param modifiers Full state to store.
- * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the callback.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param max_state_message_id
+ *        ID of the last stateful message before @a state_hash_message_id.
+ * @param state_hash_message_id
+ *        ID of the message that contains the state_hash PSYC header variable.
+ * @param modifier_count
+ *        Number of elements in the @a modifiers array.
+ * @param modifiers
+ *        Full state to store.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the callback.
  *
  * @return Handle that can be used to cancel the operation.
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h,
                              const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
-                             uint64_t message_id,
+                             uint64_t max_state_message_id,
+                             uint64_t state_hash_message_id,
                              size_t modifier_count,
-                             const struct GNUNET_ENV_Modifier *modifiers,
-                             GNUNET_PSYCSTORE_ResultCallback rcb,
-                             void *rcb_cls);
+                             const struct GNUNET_PSYC_Modifier *modifiers,
+                             GNUNET_PSYCSTORE_ResultCallback result_cb,
+                             void *cls);
 
 
 
@@ -528,10 +555,14 @@ GNUNET_PSYCSTORE_state_sync (struct GNUNET_PSYCSTORE_Handle *h,
  *
  * Delete all state variables stored for the given channel.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the callback.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the callback.
  *
  * @return Handle that can be used to cancel the operation.
  */
@@ -539,19 +570,25 @@ struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_reset (struct GNUNET_PSYCSTORE_Handle *h,
                               const struct GNUNET_CRYPTO_EddsaPublicKey
                               *channel_key,
-                              GNUNET_PSYCSTORE_ResultCallback rcb,
-                              void *rcb_cls);
+                              GNUNET_PSYCSTORE_ResultCallback result_cb,
+                              void *cls);
 
 
 /**
  * Update signed values of state variables in the state store.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param message_id Message ID that contained the state @a hash.
- * @param hash Hash of the serialized full state.
- * @param rcb Callback to call with the result of the operation.
- * @param rcb_cls Closure for the callback.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param message_id
+ *        Message ID that contained the state @a hash.
+ * @param hash
+ *        Hash of the serialized full state.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the callback.
  *
  */
 struct GNUNET_PSYCSTORE_OperationHandle *
@@ -559,36 +596,46 @@ GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h,
                                     const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                     uint64_t message_id,
                                     const struct GNUNET_HashCode *hash,
-                                    GNUNET_PSYCSTORE_ResultCallback rcb,
-                                    void *rcb_cls);
+                                    GNUNET_PSYCSTORE_ResultCallback result_cb,
+                                    void *cls);
 
 
 /**
  * Function called with the value of a state variable.
  *
- * @param cls Closure.
- * @param name Name of the state variable.  A NULL value indicates that there are no more
+ * @param cls
+ *        Closure.
+ * @param name
+ *        Name of the state variable.  A NULL value indicates that there are no more
  *        state variables to be returned.
- * @param value Value of the state variable.
- * @param value_size Number of bytes in @a value.
+ * @param value
+ *        Value of the state variable.
+ * @param value_size
+ *        Number of bytes in @a value.
  *
  * @return #GNUNET_NO to stop calling this callback with further variables,
  *         #GNUNET_YES to continue.
  */;
 typedef int
 (*GNUNET_PSYCSTORE_StateCallback) (void *cls, const char *name,
-                                   const void *value, size_t value_size);
+                                   const void *value, uint32_t value_size);
 
 
 /**
  * Retrieve the best matching state variable.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param name Name of variable to match, the returned variable might be less specific.
- * @param scb Callback to return the matching state variable.
- * @param rcb Callback to call with the result of the operation.
- * @param cls Closure for the callbacks.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param name
+ *        Name of variable to match, the returned variable might be less specific.
+ * @param state_cb
+ *        Callback to return the matching state variable.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the callbacks.
  *
  * @return Handle that can be used to cancel the operation.
  */
@@ -596,20 +643,26 @@ struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
                             const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                             const char *name,
-                            GNUNET_PSYCSTORE_StateCallback scb,
-                            GNUNET_PSYCSTORE_ResultCallback rcb,
+                            GNUNET_PSYCSTORE_StateCallback state_cb,
+                            GNUNET_PSYCSTORE_ResultCallback result_cb,
                             void *cls);
 
 
 /**
  * Retrieve all state variables for a channel with the given prefix.
  *
- * @param h Handle for the PSYCstore.
- * @param channel_key The channel we are interested in.
- * @param name_prefix Prefix of state variable names to match.
- * @param scb Callback to return matching state variables.
- * @param rcb Callback to call with the result of the operation.
- * @param cls Closure for the callbacks.
+ * @param h
+ *        Handle for the PSYCstore.
+ * @param channel_key
+ *        The channel we are interested in.
+ * @param name_prefix
+ *        Prefix of state variable names to match.
+ * @param state_cb
+ *        Callback to return matching state variables.
+ * @param result_cb
+ *        Callback to call with the result of the operation.
+ * @param cls
+ *        Closure for the callbacks.
  *
  * @return Handle that can be used to cancel the operation.
  */
@@ -617,8 +670,8 @@ struct GNUNET_PSYCSTORE_OperationHandle *
 GNUNET_PSYCSTORE_state_get_prefix (struct GNUNET_PSYCSTORE_Handle *h,
                                    const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
                                    const char *name_prefix,
-                                   GNUNET_PSYCSTORE_StateCallback scb,
-                                   GNUNET_PSYCSTORE_ResultCallback rcb,
+                                   GNUNET_PSYCSTORE_StateCallback state_cb,
+                                   GNUNET_PSYCSTORE_ResultCallback result_cb,
                                    void *cls);
 
 
@@ -627,7 +680,7 @@ GNUNET_PSYCSTORE_state_get_prefix (struct GNUNET_PSYCSTORE_Handle *h,
  *
  * @param op Handle for the operation to cancel.
  */
-void
+int
 GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *op);
 
 
@@ -642,4 +695,5 @@ GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *op);
 
 /* ifndef GNUNET_PSYCSTORE_SERVICE_H */
 #endif
-/* end of gnunet_psycstore_service.h */
+
+/** @} */  /* end of group */