aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/plugin_datacache.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-25 22:24:42 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-25 22:24:42 +0000
commitc890b76cde9288a8d9f2faa3046fbb06341c8082 (patch)
treeb2c072b5ad2fba45a6bf5856209963fbf37375c3 /src/datacache/plugin_datacache.h
parent2ec742c593419e3225fa87dcf44ca96fb62d62b5 (diff)
downloadgnunet-c890b76cde9288a8d9f2faa3046fbb06341c8082.tar.gz
gnunet-c890b76cde9288a8d9f2faa3046fbb06341c8082.zip
towards datacache implementation
Diffstat (limited to 'src/datacache/plugin_datacache.h')
-rw-r--r--src/datacache/plugin_datacache.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h
new file mode 100644
index 000000000..e099cd31d
--- /dev/null
+++ b/src/datacache/plugin_datacache.h
@@ -0,0 +1,159 @@
1/*
2 This file is part of GNUnet
3 (C) 2006, 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 datacache/plugin_datacache.h
23 * @brief API for database backends for the datacache
24 * @author Christian Grothoff
25 */
26#ifndef PLUGIN_DATACACHE_H
27#define PLUGIN_DATACACHE_H
28
29#include "gnunet_datacache_lib.h"
30
31#ifdef __cplusplus
32extern "C"
33{
34#if 0 /* keep Emacsens' auto-indent happy */
35}
36#endif
37#endif
38
39
40/**
41 * Function called by plugins to notify the datacache
42 * about content deletions.
43 *
44 * @param cls closure
45 * @param key key of the content that was deleted
46 * @param size number of bytes that were made available
47 */
48typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
49 const GNUNET_HashCode *key,
50 uint32_t size);
51
52
53/**
54 * The datastore service will pass a pointer to a struct
55 * of this type as the first and only argument to the
56 * entry point of each datastore plugin.
57 */
58struct GNUNET_DATACACHE_PluginEnvironment
59{
60
61 /**
62 * Scheduler to use.
63 */
64 struct GNUNET_SCHEDULER_Handle *sched;
65
66 /**
67 * Configuration to use.
68 */
69 struct GNUNET_CONFIGURATION_Handle *cfg;
70
71 /**
72 * Configuration section to use.
73 */
74 const char *section;
75
76 /**
77 * Closure to use for callbacks.
78 */
79 void *cls;
80
81 /**
82 * Function to call whenever the plugin needs to
83 * discard content that it was asked to store.
84 */
85 GNUNET_DATACACHE_DeleteNotifyCallback delete_notify;
86
87 /**
88 * How much space are we allowed to use?
89 */
90 unsigned long long quota;
91
92};
93
94
95/**
96 * @brief struct returned by the initialization function of the plugin
97 */
98struct GNUNET_DATACACHE_PluginFunctions {
99
100 /**
101 * Closure to pass to all plugin functions.
102 */
103 void *cls;
104
105 /**
106 * Store an item in the datastore.
107 *
108 * @param key key to store data under
109 * @param size number of bytes in data
110 * @param data data to store
111 * @param type type of the value
112 * @param discard_time when to discard the value in any case
113 * @return 0 on error, number of bytes used otherwise
114 */
115 uint32_t (*put) (void *cls,
116 const GNUNET_HashCode * key,
117 uint32_t size,
118 const char *data,
119 uint32_t type,
120 struct GNUNET_TIME_Absolute discard_time);
121
122
123 /**
124 * Iterate over the results for a particular key
125 * in the datastore.
126 *
127 * @param key
128 * @param type entries of which type are relevant?
129 * @param iter maybe NULL (to just count)
130 * @return the number of results found
131 */
132 unsigned int (*get) (void *cls,
133 const GNUNET_HashCode * key,
134 uint32_t type,
135 GNUNET_DATACACHE_Iterator iter,
136 void *iter_cls);
137
138
139 /**
140 * Delete the entry with the lowest expiration value
141 * from the datacache right now.
142 *
143 * @return GNUNET_OK on success, GNUNET_SYSERR on error
144 */
145 int (*del) (void *cls);
146
147
148};
149
150
151#if 0 /* keep Emacsens' auto-indent happy */
152{
153#endif
154#ifdef __cplusplus
155}
156#endif
157
158/* end of plugin_datacache.h */
159#endif