aboutsummaryrefslogtreecommitdiff
path: root/src/datacache
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-11-05 21:54:44 +0000
committerChristian Grothoff <christian@grothoff.org>2010-11-05 21:54:44 +0000
commitbdc3b54372a92874c2ecb58069eac5bdfe6fcddc (patch)
tree575c606a8f81c1f0baabad43bf34789023513ee7 /src/datacache
parentf0963cfb7a694f9a7c7ff28471660242529f00a8 (diff)
downloadgnunet-bdc3b54372a92874c2ecb58069eac5bdfe6fcddc.tar.gz
gnunet-bdc3b54372a92874c2ecb58069eac5bdfe6fcddc.zip
moving plugin headers
Diffstat (limited to 'src/datacache')
-rw-r--r--src/datacache/datacache.c2
-rw-r--r--src/datacache/plugin_datacache.h158
-rw-r--r--src/datacache/plugin_datacache_mysql.c2
-rw-r--r--src/datacache/plugin_datacache_postgres.c2
-rw-r--r--src/datacache/plugin_datacache_sqlite.c2
-rw-r--r--src/datacache/plugin_datacache_template.c2
6 files changed, 5 insertions, 163 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 9bb0f14b9..10b2721ee 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -27,7 +27,7 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_datacache_lib.h" 28#include "gnunet_datacache_lib.h"
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "plugin_datacache.h" 30#include "gnunet_datacache_plugin.h"
31 31
32/** 32/**
33 * Internal state of the datacache library. 33 * Internal state of the datacache library.
diff --git a/src/datacache/plugin_datacache.h b/src/datacache/plugin_datacache.h
deleted file mode 100644
index 850d3961e..000000000
--- a/src/datacache/plugin_datacache.h
+++ /dev/null
@@ -1,158 +0,0 @@
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 size_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 /**
63 * Configuration to use.
64 */
65 const struct GNUNET_CONFIGURATION_Handle *cfg;
66
67 /**
68 * Configuration section to use.
69 */
70 const char *section;
71
72 /**
73 * Closure to use for callbacks.
74 */
75 void *cls;
76
77 /**
78 * Function to call whenever the plugin needs to
79 * discard content that it was asked to store.
80 */
81 GNUNET_DATACACHE_DeleteNotifyCallback delete_notify;
82
83 /**
84 * How much space are we allowed to use?
85 */
86 unsigned long long quota;
87
88};
89
90
91/**
92 * @brief struct returned by the initialization function of the plugin
93 */
94struct GNUNET_DATACACHE_PluginFunctions {
95
96 /**
97 * Closure to pass to all plugin functions.
98 */
99 void *cls;
100
101 /**
102 * Store an item in the datastore.
103 *
104 * @param cls closure (internal context for the plugin)
105 * @param size number of bytes in data
106 * @param data data to store
107 * @param type type of the value
108 * @param discard_time when to discard the value in any case
109 * @return 0 on error, number of bytes used otherwise
110 */
111 size_t (*put) (void *cls,
112 const GNUNET_HashCode * key,
113 size_t size,
114 const char *data,
115 enum GNUNET_BLOCK_Type type,
116 struct GNUNET_TIME_Absolute discard_time);
117
118
119 /**
120 * Iterate over the results for a particular key
121 * in the datastore.
122 *
123 * @param cls closure (internal context for the plugin)
124 * @param key
125 * @param type entries of which type are relevant?
126 * @param iter maybe NULL (to just count)
127 * @param iter_cls closure for iter
128 * @return the number of results found
129 */
130 unsigned int (*get) (void *cls,
131 const GNUNET_HashCode * key,
132 enum GNUNET_BLOCK_Type type,
133 GNUNET_DATACACHE_Iterator iter,
134 void *iter_cls);
135
136
137 /**
138 * Delete the entry with the lowest expiration value
139 * from the datacache right now.
140 *
141 * @param cls closure (internal context for the plugin)
142 * @return GNUNET_OK on success, GNUNET_SYSERR on error
143 */
144 int (*del) (void *cls);
145
146
147};
148
149
150#if 0 /* keep Emacsens' auto-indent happy */
151{
152#endif
153#ifdef __cplusplus
154}
155#endif
156
157/* end of plugin_datacache.h */
158#endif
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c
index 7936e0a1b..4a78a96ac 100644
--- a/src/datacache/plugin_datacache_mysql.c
+++ b/src/datacache/plugin_datacache_mysql.c
@@ -79,7 +79,7 @@
79 */ 79 */
80#include "platform.h" 80#include "platform.h"
81#include "gnunet_util_lib.h" 81#include "gnunet_util_lib.h"
82#include "plugin_datacache.h" 82#include "gnunet_datacache_plugin.h"
83#include <mysql/mysql.h> 83#include <mysql/mysql.h>
84 84
85#define DEBUG_DATACACHE_MYSQL GNUNET_NO 85#define DEBUG_DATACACHE_MYSQL GNUNET_NO
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index 75d644da9..182341b98 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -25,7 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "plugin_datacache.h" 28#include "gnunet_datacache_plugin.h"
29#include <postgresql/libpq-fe.h> 29#include <postgresql/libpq-fe.h>
30 30
31#define DEBUG_POSTGRES GNUNET_NO 31#define DEBUG_POSTGRES GNUNET_NO
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 7674402c7..b5d0ea715 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -25,7 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "plugin_datacache.h" 28#include "gnunet_datacache_plugin.h"
29#include <sqlite3.h> 29#include <sqlite3.h>
30 30
31#define DEBUG_DATACACHE_SQLITE GNUNET_NO 31#define DEBUG_DATACACHE_SQLITE GNUNET_NO
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c
index 25e4c9a42..60862dac2 100644
--- a/src/datacache/plugin_datacache_template.c
+++ b/src/datacache/plugin_datacache_template.c
@@ -25,7 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "plugin_datacache.h" 28#include "gnunet_datacache_plugin.h"
29 29
30 30
31/** 31/**