2 This file is part of GNUnet
3 (C) 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file datastore/datastore_api.c
23 * @brief Management for the datastore for files stored on a GNUnet node
24 * @author Christian Grothoff
28 #include "gnunet_datastore_service.h"
29 #include "datastore.h"
32 * Handle to the datastore service.
34 struct GNUNET_DATASTORE_Handle
40 * Connect to the datastore service.
42 * @param cfg configuration to use
43 * @param sched scheduler to use
44 * @return handle to use to access the service
46 struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct
47 GNUNET_CONFIGURATION_Handle
50 GNUNET_SCHEDULER_Handle
58 * Disconnect from the datastore service (and free
59 * associated resources).
61 * @param h handle to the datastore
62 * @param drop set to GNUNET_YES to delete all data in datastore (!)
64 void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
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)
75 unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h)
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.
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
96 GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
97 const GNUNET_HashCode * key,
103 struct GNUNET_TIME_Absolute expiration)
109 * Iterate over the results for a particular key
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
120 GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
121 const GNUNET_HashCode * key,
123 GNUNET_DATASTORE_Iterator iter, void *iter_cls)
129 * Get a random value from the datastore.
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
138 GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
139 GNUNET_DATASTORE_Iterator iter, void *iter_cls)
145 * Explicitly remove some content from the database.
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
153 GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
154 const GNUNET_HashCode * key,
155 uint32_t size, const void *data)
160 /* end of datastore_api.c */