aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datastore_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_datastore_service.h')
-rw-r--r--src/include/gnunet_datastore_service.h187
1 files changed, 187 insertions, 0 deletions
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
new file mode 100644
index 000000000..b20c6b100
--- /dev/null
+++ b/src/include/gnunet_datastore_service.h
@@ -0,0 +1,187 @@
1/*
2 This file is part of GNUnet
3 (C) 2004, 2005, 2006, 2007, 2009 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_datastore_service.h
23 * @brief API that can be used manage the
24 * datastore for files stored on a GNUnet node;
25 * note that the datastore is NOT responsible for
26 * on-demand encoding, that is achieved using
27 * a special kind of entry.
28 * @author Christian Grothoff
29 */
30
31#ifndef GNUNET_DATASTORE_SERVICE_H
32#define GNUNET_DATASTORE_SERVICE_H
33
34#include "gnunet_core.h"
35
36#ifdef __cplusplus
37extern "C"
38{
39#if 0 /* keep Emacsens' auto-indent happy */
40}
41#endif
42#endif
43
44
45/**
46 * Handle to the datastore service.
47 */
48struct GNUNET_DATASTORE_Handle;
49
50
51/**
52 * An iterator over a set of items stored in the datastore.
53 *
54 * @param cls closure
55 * @param key key for the content
56 * @param size number of bytes in data
57 * @param data content stored
58 * @param type type of the content
59 * @param priority priority of the content
60 * @param anonymity anonymity-level for the content
61 * @param expiration expiration time for the content
62 * @param uid unique identifier for the datum;
63 * maybe 0 if no unique identifier is available
64 *
65 * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue,
66 * GNUNET_NO to delete the item and continue (if supported)
67 */
68typedef int (*GNUNET_DATASTORE_Iterator) (void *cls,
69 const GNUNET_HashCode * key,
70 uint32_t size,
71 const void *data,
72 uint32_t type,
73 uint32_t priority,
74 uint32_t anonymity,
75 struct GNUNET_TIME_Absolute
76 expiration, unsigned long long uid);
77
78/**
79 * Connect to the datastore service.
80 *
81 * @param cfg configuration to use
82 * @param sched scheduler to use
83 * @return handle to use to access the service
84 */
85struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct
86 GNUNET_CONFIGURATION_Handle
87 *cfg,
88 struct
89 GNUNET_SCHEDULER_Handle
90 *sched);
91
92
93/**
94 * Disconnect from the datastore service (and free
95 * associated resources).
96 * @param h handle to the datastore
97 */
98void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h);
99
100
101/**
102 * Get the current on-disk size of the datastore.
103 * @param h handle to the datastore
104 * @return size estimate, -1 if datastore is not available (yet)
105 */
106unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h);
107
108
109/**
110 * Store an item in the datastore. If the item is already present,
111 * the priorities are summed up and the higher expiration time and
112 * lower anonymity level is used.
113 *
114 * @param h handle to the datastore
115 * @param key key for the value
116 * @param size number of bytes in data
117 * @param data content stored
118 * @param type type of the content
119 * @param priority priority of the content
120 * @param anonymity anonymity-level for the content
121 * @param expiration expiration time for the content
122 */
123void
124GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
125 const GNUNET_HashCode * key,
126 uint32_t size,
127 const void *data,
128 unit32_t type,
129 uint32_t priority,
130 uint32_t anonymity,
131 struct GNUNET_TIME_Absolute expiration);
132
133/**
134 * Iterate over the results for a particular key
135 * in the datastore.
136 *
137 * @param h handle to the datastore
138 * @param key maybe NULL (to match all entries)
139 * @param type desired type, 0 for any
140 * @param iter function to call on each matching value;
141 * will be called once with a NULL value at the end
142 * @param iter_cls closure for iter
143 */
144void
145GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
146 const GNUNET_HashCode * key,
147 uint32_t type,
148 GNUNET_DATASTORE_Iterator iter, void *iter_cls);
149
150
151/**
152 * Get a random value from the datastore.
153 *
154 * @param h handle to the datastore
155 * @param iter function to call on each matching value;
156 * will be called exactly once; if no values
157 * are available, the value will be NULL.
158 * @param iter_cls closure for iter
159 */
160void
161GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
162 GNUNET_DATASTORE_Iterator iter, void *iter_cls);
163
164
165/**
166 * Explicitly remove some content from the database.
167 *
168 * @param h handle to the datastore
169 * @param key key for the value
170 * @param size number of bytes in data
171 * @param data content stored
172 */
173void
174GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
175 const GNUNET_HashCode * key,
176 uint32_t size, const void *data);
177
178
179#if 0 /* keep Emacsens' auto-indent happy */
180{
181#endif
182#ifdef __cplusplus
183}
184#endif
185
186/* end of gnunet_datastore_service.h */
187#endif