cc563ba799bcc8dcf8292b69c49ec1e10f478c89
[oweals/gnunet.git] / src / datastore / datastore_api.c
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 datastore/datastore_api.c
23  * @brief Management for the datastore for files stored on a GNUnet node
24  * @author Christian Grothoff
25  */
26
27 #include "platform.h"
28 #include "gnunet_datastore_service.h"
29 #include "datastore.h"
30
31 /**
32  * Handle to the datastore service.
33  */
34 struct GNUNET_DATASTORE_Handle
35 {
36 };
37
38
39 /**
40  * Connect to the datastore service.
41  *
42  * @param cfg configuration to use
43  * @param sched scheduler to use
44  * @return handle to use to access the service
45  */
46 struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct
47                                                           GNUNET_CONFIGURATION_Handle
48                                                           *cfg,
49                                                           struct
50                                                           GNUNET_SCHEDULER_Handle
51                                                           *sched)
52 {
53   return NULL;
54 }
55
56
57 /**
58  * Disconnect from the datastore service (and free
59  * associated resources).
60  *
61  * @param h handle to the datastore
62  * @param drop set to GNUNET_YES to delete all data in datastore (!)
63  */
64 void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
65                                   int drop)
66 {
67 }
68
69
70 /**
71  * Get the current on-disk size of the datastore.
72  * @param h handle to the datastore
73  * @return size estimate, -1 if datastore is not available (yet)
74  */
75 unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h)
76 {
77   return 0;
78 }
79
80
81 /**
82  * Store an item in the datastore.  If the item is already present,
83  * the priorities are summed up and the higher expiration time and
84  * lower anonymity level is used.
85  *
86  * @param h handle to the datastore
87  * @param key key for the value
88  * @param size number of bytes in data
89  * @param data content stored
90  * @param type type of the content
91  * @param priority priority of the content
92  * @param anonymity anonymity-level for the content
93  * @param expiration expiration time for the content
94  */
95 void
96 GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
97                       const GNUNET_HashCode * key,
98                       uint32_t size,
99                       const void *data,
100                       uint32_t type,
101                       uint32_t priority,
102                       uint32_t anonymity,
103                       struct GNUNET_TIME_Absolute expiration)
104 {
105 }
106
107
108 /**
109  * Iterate over the results for a particular key
110  * in the datastore.
111  *
112  * @param h handle to the datastore
113  * @param key maybe NULL (to match all entries)
114  * @param type desired type, 0 for any
115  * @param iter function to call on each matching value;
116  *        will be called once with a NULL value at the end
117  * @param iter_cls closure for iter
118  */
119 void
120 GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
121                       const GNUNET_HashCode * key,
122                       uint32_t type,
123                       GNUNET_DATASTORE_Iterator iter, void *iter_cls)
124 {
125 }
126
127
128 /**
129  * Get a random value from the datastore.
130  *
131  * @param h handle to the datastore
132  * @param iter function to call on each matching value;
133  *        will be called exactly once; if no values
134  *        are available, the value will be NULL.
135  * @param iter_cls closure for iter
136  */
137 void
138 GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
139                              GNUNET_DATASTORE_Iterator iter, void *iter_cls)
140 {
141 }
142
143
144 /**
145  * Explicitly remove some content from the database.
146  *
147  * @param h handle to the datastore
148  * @param key key for the value
149  * @param size number of bytes in data
150  * @param data content stored
151  */
152 void
153 GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
154                          const GNUNET_HashCode * key,
155                          uint32_t size, const void *data)
156 {
157 }
158
159
160 /* end of datastore_api.c */