bratao/LRN: Use-bigger-buffer-for-EnumNICs3_results
[oweals/gnunet.git] / src / include / gnunet_namestore_plugin.h
1 /*
2      This file is part of GNUnet
3      (C) 2012 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_namestore_plugin.h
23  * @brief plugin API for the namestore database backend
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_NAMESTORE_PLUGIN_H
27 #define GNUNET_NAMESTORE_PLUGIN_H
28
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_namestore_service.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0                           /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40
41
42 /**
43  * Function called by for each matching record.
44  *
45  * @param cls closure
46  * @param zone_key public key of the zone
47  * @param expire when does the corresponding block in the DHT expire (until
48  *               when should we never do a DHT lookup for the same name again)?
49  * @param name name that is being mapped (at most 255 characters long)
50  * @param rd_count number of entries in 'rd' array
51  * @param rd array of records with data to store
52  * @param signature signature of the record block, NULL if signature is unavailable (i.e. 
53  *        because the user queried for a particular record type only)
54  */
55 typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
56                                                  const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
57                                                  struct GNUNET_TIME_Absolute expire,
58                                                  const char *name,
59                                                  unsigned int rd_count,
60                                                  const struct GNUNET_NAMESTORE_RecordData *rd,
61                                                  const struct GNUNET_CRYPTO_RsaSignature *signature);
62
63
64 /**
65  * @brief struct returned by the initialization function of the plugin
66  */
67 struct GNUNET_NAMESTORE_PluginFunctions
68 {
69
70   /**
71    * Closure to pass to all plugin functions.
72    */
73   void *cls;
74
75   /**
76    * Store a record in the datastore.  Removes any existing record in the
77    * same zone with the same name.
78    *
79    * @param cls closure (internal context for the plugin)
80    * @param zone_key public key of the zone
81    * @param expire when does the corresponding block in the DHT expire (until
82    *               when should we never do a DHT lookup for the same name again)?
83    * @param name name that is being mapped (at most 255 characters long)
84    * @param rd_count number of entries in 'rd' array
85    * @param rd array of records with data to store
86    * @param signature signature of the record block, NULL if signature is unavailable (i.e. 
87    *        because the user queried for a particular record type only)
88    * @return GNUNET_OK on success
89    */
90   int (*put_records) (void *cls, 
91                       const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
92                       struct GNUNET_TIME_Absolute expire,
93                       const char *name,
94                       unsigned int rd_count,
95                       const struct GNUNET_NAMESTORE_RecordData *rd,
96                       const struct GNUNET_CRYPTO_RsaSignature *signature);
97
98
99   /**
100    * Removes any existing record in the given zone with the same name.
101    *
102    * @param cls closure (internal context for the plugin)
103    * @param zone hash of the public key of the zone
104    * @param name name to remove (at most 255 characters long)
105    * @return GNUNET_OK on success
106    */
107   int (*remove_records) (void *cls, 
108                          const GNUNET_HashCode *zone,
109                          const char *name);
110
111
112   /**
113    * Iterate over the results for a particular key and zone in the
114    * datastore.  Will return at most one result to the iterator.
115    *
116    * @param cls closure (internal context for the plugin)
117    * @param zone hash of public key of the zone, NULL to iterate over all zones
118    * @param name_hash hash of name, NULL to iterate over all records of the zone
119    * @param offset offset in the list of all matching records
120    * @param iter function to call with the result
121    * @param iter_cls closure for iter
122    * @return GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error
123    */
124   int (*iterate_records) (void *cls, 
125                           const GNUNET_HashCode *zone,
126                           const GNUNET_HashCode *name_hash,
127                           uint64_t offset,
128                           GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
129
130
131   /**
132    * Delete an entire zone (all records).  Not used in normal operation.
133    *
134    * @param cls closure (internal context for the plugin)
135    * @param zone zone to delete
136    */
137   void (*delete_zone) (void *cls,
138                        const GNUNET_HashCode *zone);
139
140
141 };
142
143
144 #if 0                           /* keep Emacsens' auto-indent happy */
145 {
146 #endif
147 #ifdef __cplusplus
148 }
149 #endif
150
151 /* end of gnunet_namestore_plugin.h */
152 #endif