use NULL value in load_path_suffix to NOT load any files
[oweals/gnunet.git] / src / include / gnunet_peerstore_plugin.h
1 /*
2      This file is part of GNUnet
3      Copyright (C) 2012, 2013 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @author Omar Tarabai
23  *
24  * @file
25  * Plugin API for the peerstore database backend
26  *
27  * @defgroup peerstore-plugin  Peer Store service plugin API
28  * Plugin API for the peerstore database backend
29  * @{
30  */
31 #ifndef GNUNET_PEERSTORE_PLUGIN_H
32 #define GNUNET_PEERSTORE_PLUGIN_H
33
34 #include "gnunet_util_lib.h"
35 #include "gnunet_peerstore_service.h"
36
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0                           /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44
45
46 /**
47  * @brief struct returned by the initialization function of the plugin
48  */
49 struct GNUNET_PEERSTORE_PluginFunctions
50 {
51   /**
52    * Closure to pass to all plugin functions.
53    */
54   void *cls;
55
56   /**
57    * Store a record in the peerstore.
58    * Key is the combination of sub system and peer identity.
59    * One key can store multiple values.
60    *
61    * @param cls closure (internal context for the plugin)
62    * @param sub_system name of the GNUnet sub system responsible
63    * @param peer peer identity
64    * @param value value to be stored
65    * @param size size of value to be stored
66    * @param expiry absolute time after which the record is (possibly) deleted
67    * @param options options related to the store operation
68    * @param cont continuation called when record is stored
69    * @param cont_cls continuation closure
70    * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
71    */
72   int
73   (*store_record) (void *cls,
74                    const char *sub_system,
75                    const struct GNUNET_PeerIdentity *peer,
76                    const char *key,
77                    const void *value,
78                    size_t size,
79                    struct GNUNET_TIME_Absolute expiry,
80                    enum GNUNET_PEERSTORE_StoreOption options,
81                    GNUNET_PEERSTORE_Continuation cont,
82                    void *cont_cls);
83
84   /**
85    * Iterate over the records given an optional peer id
86    * and/or key.
87    *
88    * @param cls closure (internal context for the plugin)
89    * @param sub_system name of sub system
90    * @param peer Peer identity (can be NULL)
91    * @param key entry key string (can be NULL)
92    * @param iter function to call asynchronously with the results, terminated
93    * by a NULL result
94    * @param iter_cls closure for @a iter
95    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
96    * called
97    */
98   int
99   (*iterate_records) (void *cls,
100                       const char *sub_system,
101                       const struct GNUNET_PeerIdentity *peer,
102                       const char *key,
103                       GNUNET_PEERSTORE_Processor iter,
104                       void *iter_cls);
105
106   /**
107    * Delete expired records (expiry < now)
108    *
109    * @param cls closure (internal context for the plugin)
110    * @param now time to use as reference
111    * @param cont continuation called with the number of records expired
112    * @param cont_cls continuation closure
113    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
114    * called
115    */
116   int
117   (*expire_records) (void *cls,
118                      struct GNUNET_TIME_Absolute now,
119                      GNUNET_PEERSTORE_Continuation cont,
120                      void *cont_cls);
121 };
122
123
124 #if 0                           /* keep Emacsens' auto-indent happy */
125 {
126 #endif
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif
132
133 /** @} */  /* end of group */