adding number of preferences to allow iterating over preferences
[oweals/gnunet.git] / src / include / gnunet_datacache_plugin.h
index cdacd474bd8e3da25bd7ec7cd59d018a6e642a9c..347ed9a59ca29f0e65705bedc4a67fdfc63a7400 100644 (file)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet
-     (C) 2006, 2009 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors)
 
      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 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -40,14 +40,14 @@ extern "C"
 /**
  * Function called by plugins to notify the datacache
  * about content deletions.
- * 
+ *
  * @param cls closure
  * @param key key of the content that was deleted
  * @param size number of bytes that were made available
  */
-typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
-                                                     const GNUNET_HashCode *key,
-                                                     size_t size);
+typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback) (void *cls,
+                                                       const struct GNUNET_HashCode *
+                                                       key, size_t size);
 
 
 /**
@@ -57,7 +57,7 @@ typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
  */
 struct GNUNET_DATACACHE_PluginEnvironment
 {
-  
+
 
   /**
    * Configuration to use.
@@ -91,11 +91,12 @@ struct GNUNET_DATACACHE_PluginEnvironment
 /**
  * @brief struct returned by the initialization function of the plugin
  */
-struct GNUNET_DATACACHE_PluginFunctions {
+struct GNUNET_DATACACHE_PluginFunctions
+{
 
   /**
    * Closure to pass to all plugin functions.
-   */ 
+   */
   void *cls;
 
   /**
@@ -106,14 +107,15 @@ struct GNUNET_DATACACHE_PluginFunctions {
    * @param data data to store
    * @param type type of the value
    * @param discard_time when to discard the value in any case
-   * @return 0 on error, number of bytes used otherwise
+   * @param path_info_len number of entries in 'path_info'
+   * @param path_info a path through the network
+   * @return 0 if duplicate, -1 on error, number of bytes used otherwise
    */
-  size_t (*put) (void *cls,
-                const GNUNET_HashCode * key,
-                size_t size,
-                const char *data,
-                enum GNUNET_BLOCK_Type type,
-                struct GNUNET_TIME_Absolute discard_time);
+  ssize_t (*put) (void *cls, const struct GNUNET_HashCode * key, size_t size,
+                 const char *data, enum GNUNET_BLOCK_Type type,
+                 struct GNUNET_TIME_Absolute discard_time,
+                 unsigned int path_info_len,
+                 const struct GNUNET_PeerIdentity *path_info);
 
 
   /**
@@ -127,20 +129,18 @@ struct GNUNET_DATACACHE_PluginFunctions {
    * @param iter_cls closure for iter
    * @return the number of results found
    */
-  unsigned int (*get) (void *cls,
-                      const GNUNET_HashCode * key,
-                      enum GNUNET_BLOCK_Type type,
-                      GNUNET_DATACACHE_Iterator iter,
-                      void *iter_cls);
+  unsigned int (*get) (void *cls, const struct GNUNET_HashCode * key,
+                       enum GNUNET_BLOCK_Type type,
+                       GNUNET_DATACACHE_Iterator iter, void *iter_cls);
 
 
   /**
    * Delete the entry with the lowest expiration value
    * from the datacache right now.
-   * 
+   *
    * @param cls closure (internal context for the plugin)
    * @return GNUNET_OK on success, GNUNET_SYSERR on error
-   */ 
+   */
   int (*del) (void *cls);