aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-18 13:33:10 +0000
committerChristian Grothoff <christian@grothoff.org>2015-07-18 13:33:10 +0000
commit957ba741a643ac853f7cd6c00f05f41cf57d8d59 (patch)
tree98acdb5bcf1e0cf959100e7e0416a14ccd270550
parentd38544730123a1f365ef287a7e88060d97b266b7 (diff)
downloadgnunet-957ba741a643ac853f7cd6c00f05f41cf57d8d59.tar.gz
gnunet-957ba741a643ac853f7cd6c00f05f41cf57d8d59.zip
-adding missing 'const' decls, fixing indentation / doxygen a bit
-rw-r--r--src/datastore/gnunet-service-datastore.c57
-rw-r--r--src/datastore/perf_plugin_datastore.c19
-rw-r--r--src/datastore/test_plugin_datastore.c31
-rw-r--r--src/include/gnunet_datastore_plugin.h118
4 files changed, 159 insertions, 66 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index f8012527a..77e96c94f 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -829,9 +829,21 @@ struct PutContext
829}; 829};
830 830
831 831
832/**
833 * Put continuation.
834 *
835 * @param cls closure
836 * @param key key for the item stored
837 * @param size size of the item stored
838 * @param status #GNUNET_OK or #GNUNET_SYSERROR
839 * @param msg error message on error
840 */
832static void 841static void
833put_continuation (void *cls, const struct GNUNET_HashCode *key, uint32_t size, 842put_continuation (void *cls,
834 int status, char *msg) 843 const struct GNUNET_HashCode *key,
844 uint32_t size,
845 int status,
846 const char *msg)
835{ 847{
836 struct GNUNET_SERVER_Client *client = cls; 848 struct GNUNET_SERVER_Client *client = cls;
837 849
@@ -877,7 +889,9 @@ execute_put (struct GNUNET_SERVER_Client *client, const struct DataMessage *dm)
877 889
878 890
879static void 891static void
880check_present_continuation (void *cls, int status, char *msg) 892check_present_continuation (void *cls,
893 int status,
894 const char *msg)
881{ 895{
882 struct GNUNET_SERVER_Client *client = cls; 896 struct GNUNET_SERVER_Client *client = cls;
883 897
@@ -890,7 +904,7 @@ check_present_continuation (void *cls, int status, char *msg)
890 * Function that will check if the given datastore entry 904 * Function that will check if the given datastore entry
891 * matches the put and if none match executes the put. 905 * matches the put and if none match executes the put.
892 * 906 *
893 * @param cls closure, pointer to the client (of type 'struct PutContext'). 907 * @param cls closure, pointer to the client (of type `struct PutContext`).
894 * @param key key for the content 908 * @param key key for the content
895 * @param size number of bytes in data 909 * @param size number of bytes in data
896 * @param data content stored 910 * @param data content stored
@@ -900,14 +914,18 @@ check_present_continuation (void *cls, int status, char *msg)
900 * @param expiration expiration time for the content 914 * @param expiration expiration time for the content
901 * @param uid unique identifier for the datum; 915 * @param uid unique identifier for the datum;
902 * maybe 0 if no unique identifier is available 916 * maybe 0 if no unique identifier is available
903 * 917 * @return #GNUNET_OK usually
904 * @return GNUNET_OK usually 918 * #GNUNET_NO to delete the item
905 * GNUNET_NO to delete the item
906 */ 919 */
907static int 920static int
908check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size, 921check_present (void *cls,
909 const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, 922 const struct GNUNET_HashCode *key,
910 uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, 923 uint32_t size,
924 const void *data,
925 enum GNUNET_BLOCK_Type type,
926 uint32_t priority,
927 uint32_t anonymity,
928 struct GNUNET_TIME_Absolute expiration,
911 uint64_t uid) 929 uint64_t uid)
912{ 930{
913 struct PutContext *pc = cls; 931 struct PutContext *pc = cls;
@@ -932,10 +950,12 @@ check_present (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
932 if ((ntohl (dm->priority) > 0) || 950 if ((ntohl (dm->priority) > 0) ||
933 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us > 951 (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value_us >
934 expiration.abs_value_us)) 952 expiration.abs_value_us))
935 plugin->api->update (plugin->api->cls, uid, 953 plugin->api->update (plugin->api->cls,
954 uid,
936 (int32_t) ntohl (dm->priority), 955 (int32_t) ntohl (dm->priority),
937 GNUNET_TIME_absolute_ntoh (dm->expiration), 956 GNUNET_TIME_absolute_ntoh (dm->expiration),
938 check_present_continuation, pc->client); 957 &check_present_continuation,
958 pc->client);
939 else 959 else
940 { 960 {
941 transmit_status (pc->client, GNUNET_NO, NULL); 961 transmit_status (pc->client, GNUNET_NO, NULL);
@@ -1008,8 +1028,13 @@ handle_put (void *cls, struct GNUNET_SERVER_Client *client,
1008 pc->client = client; 1028 pc->client = client;
1009 GNUNET_SERVER_client_keep (client); 1029 GNUNET_SERVER_client_keep (client);
1010 memcpy (&pc[1], dm, size + sizeof (struct DataMessage)); 1030 memcpy (&pc[1], dm, size + sizeof (struct DataMessage));
1011 plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, 1031 plugin->api->get_key (plugin->api->cls,
1012 ntohl (dm->type), &check_present, pc); 1032 0,
1033 &dm->key,
1034 &vhash,
1035 ntohl (dm->type),
1036 &check_present,
1037 pc);
1013 return; 1038 return;
1014 } 1039 }
1015 execute_put (client, dm); 1040 execute_put (client, dm);
@@ -1069,7 +1094,9 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client,
1069 1094
1070 1095
1071static void 1096static void
1072update_continuation (void *cls, int status, char *msg) 1097update_continuation (void *cls,
1098 int status,
1099 const char *msg)
1073{ 1100{
1074 struct GNUNET_SERVER_Client *client = cls; 1101 struct GNUNET_SERVER_Client *client = cls;
1075 1102
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index d31d5facf..a91ec19ed 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -99,12 +99,25 @@ disk_utilization_change_cb (void *cls, int delta)
99 99
100 100
101static void 101static void
102test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 102test (void *cls,
103 const struct GNUNET_SCHEDULER_TaskContext *tc);
103 104
104 105
106/**
107 * Put continuation.
108 *
109 * @param cls closure
110 * @param key key for the item stored
111 * @param size size of the item stored
112 * @param status #GNUNET_OK or #GNUNET_SYSERROR
113 * @param msg error message on error
114 */
105static void 115static void
106put_continuation (void *cls, const struct GNUNET_HashCode *key, 116put_continuation (void *cls,
107 uint32_t size, int status, char *msg) 117 const struct GNUNET_HashCode *key,
118 uint32_t size,
119 int status,
120 const char *msg)
108{ 121{
109 struct CpsRunContext *crc = cls; 122 struct CpsRunContext *crc = cls;
110 123
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c
index b367b1a7f..d60dc3cc2 100644
--- a/src/datastore/test_plugin_datastore.c
+++ b/src/datastore/test_plugin_datastore.c
@@ -84,12 +84,25 @@ disk_utilization_change_cb (void *cls, int delta)
84 84
85 85
86static void 86static void
87test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 87test (void *cls,
88 const struct GNUNET_SCHEDULER_TaskContext *tc);
88 89
89 90
91/**
92 * Put continuation.
93 *
94 * @param cls closure
95 * @param key key for the item stored
96 * @param size size of the item stored
97 * @param status #GNUNET_OK or #GNUNET_SYSERROR
98 * @param msg error message on error
99 */
90static void 100static void
91put_continuation (void *cls, const struct GNUNET_HashCode *key, 101put_continuation (void *cls,
92 uint32_t size, int status, char *msg) 102 const struct GNUNET_HashCode *key,
103 uint32_t size,
104 int status,
105 const char *msg)
93{ 106{
94 struct CpsRunContext *crc = cls; 107 struct CpsRunContext *crc = cls;
95 static unsigned long long os; 108 static unsigned long long os;
@@ -238,7 +251,9 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
238 251
239 252
240static void 253static void
241update_continuation (void *cls, int status, char *msg) 254update_continuation (void *cls,
255 int status,
256 const char *msg)
242{ 257{
243 struct CpsRunContext *crc = cls; 258 struct CpsRunContext *crc = cls;
244 259
@@ -285,8 +300,12 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
285 GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc); 300 GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc);
286 break; 301 break;
287 case RP_UPDATE: 302 case RP_UPDATE:
288 crc->api->update (crc->api->cls, guid, 1, GNUNET_TIME_UNIT_ZERO_ABS, 303 crc->api->update (crc->api->cls,
289 update_continuation, crc); 304 guid,
305 1,
306 GNUNET_TIME_UNIT_ZERO_ABS,
307 &update_continuation,
308 crc);
290 break; 309 break;
291 310
292 case RP_ITER_ZERO: 311 case RP_ITER_ZERO:
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h
index fc13645e5..08093d55e 100644
--- a/src/include/gnunet_datastore_plugin.h
+++ b/src/include/gnunet_datastore_plugin.h
@@ -48,7 +48,9 @@
48 * @param delta change in disk utilization, 48 * @param delta change in disk utilization,
49 * 0 for "reset to empty" 49 * 0 for "reset to empty"
50 */ 50 */
51typedef void (*DiskUtilizationChange) (void *cls, int delta); 51typedef void
52(*GNUNET_DATASTORE_DiskUtilizationChange) (void *cls,
53 int delta);
52 54
53 55
54/** 56/**
@@ -66,7 +68,7 @@ struct GNUNET_DATASTORE_PluginEnvironment
66 /** 68 /**
67 * Function to call on disk utilization change. 69 * Function to call on disk utilization change.
68 */ 70 */
69 DiskUtilizationChange duc; 71 GNUNET_DATASTORE_DiskUtilizationChange duc;
70 72
71 /** 73 /**
72 * Closure. 74 * Closure.
@@ -91,12 +93,17 @@ struct GNUNET_DATASTORE_PluginEnvironment
91 * @return #GNUNET_OK to keep the item 93 * @return #GNUNET_OK to keep the item
92 * #GNUNET_NO to delete the item 94 * #GNUNET_NO to delete the item
93 */ 95 */
94typedef int (*PluginDatumProcessor) (void *cls, const struct GNUNET_HashCode * key, 96typedef int
95 uint32_t size, const void *data, 97(*PluginDatumProcessor) (void *cls,
96 enum GNUNET_BLOCK_Type type, 98 const struct GNUNET_HashCode *key,
97 uint32_t priority, uint32_t anonymity, 99 uint32_t size,
98 struct GNUNET_TIME_Absolute expiration, 100 const void *data,
99 uint64_t uid); 101 enum GNUNET_BLOCK_Type type,
102 uint32_t priority,
103 uint32_t anonymity,
104 struct GNUNET_TIME_Absolute expiration,
105 uint64_t uid);
106
100 107
101/** 108/**
102 * Get an estimate of how much space the database is 109 * Get an estimate of how much space the database is
@@ -109,7 +116,9 @@ typedef int (*PluginDatumProcessor) (void *cls, const struct GNUNET_HashCode * k
109 * @param estimate location to store estimate 116 * @param estimate location to store estimate
110 * @return number of bytes used on disk 117 * @return number of bytes used on disk
111 */ 118 */
112typedef void (*PluginEstimateSize) (void *cls, unsigned long long *estimate); 119typedef void
120(*PluginEstimateSize) (void *cls,
121 unsigned long long *estimate);
113 122
114 123
115/** 124/**
@@ -118,11 +127,15 @@ typedef void (*PluginEstimateSize) (void *cls, unsigned long long *estimate);
118 * @param cls closure 127 * @param cls closure
119 * @param key key for the item stored 128 * @param key key for the item stored
120 * @param size size of the item stored 129 * @param size size of the item stored
121 * @param status GNUNET_OK or GNUNET_SYSERROR 130 * @param status #GNUNET_OK or #GNUNET_SYSERROR
122 * @param msg error message on error 131 * @param msg error message on error
123 */ 132 */
124typedef void (*PluginPutCont) (void *cls, const struct GNUNET_HashCode *key, 133typedef void
125 uint32_t size, int status, char *msg); 134(*PluginPutCont) (void *cls,
135 const struct GNUNET_HashCode *key,
136 uint32_t size,
137 int status,
138 const char *msg);
126 139
127 140
128/** 141/**
@@ -140,15 +153,19 @@ typedef void (*PluginPutCont) (void *cls, const struct GNUNET_HashCode *key,
140 * @param replication replication-level for the content 153 * @param replication replication-level for the content
141 * @param expiration expiration time for the content 154 * @param expiration expiration time for the content
142 * @param cont continuation called with success or failure status 155 * @param cont continuation called with success or failure status
143 * @param cont_cls continuation closure 156 * @param cont_cls continuation closure for @a cont
144 */ 157 */
145typedef void (*PluginPut) (void *cls, const struct GNUNET_HashCode * key, 158typedef void
146 uint32_t size, 159(*PluginPut) (void *cls, const struct GNUNET_HashCode *key,
147 const void *data, enum GNUNET_BLOCK_Type type, 160 uint32_t size,
148 uint32_t priority, uint32_t anonymity, 161 const void *data,
149 uint32_t replication, 162 enum GNUNET_BLOCK_Type type,
150 struct GNUNET_TIME_Absolute expiration, 163 uint32_t priority,
151 PluginPutCont cont, void *cont_cls); 164 uint32_t anonymity,
165 uint32_t replication,
166 struct GNUNET_TIME_Absolute expiration,
167 PluginPutCont cont,
168 void *cont_cls);
152 169
153 170
154/** 171/**
@@ -158,9 +175,10 @@ typedef void (*PluginPut) (void *cls, const struct GNUNET_HashCode * key,
158 * @param key key in the data store, if NULL iteration is finished 175 * @param key key in the data store, if NULL iteration is finished
159 * @param count how many values are stored under this key in the datastore 176 * @param count how many values are stored under this key in the datastore
160 */ 177 */
161typedef void (*PluginKeyProcessor) (void *cls, 178typedef void
162 const struct GNUNET_HashCode *key, 179(*PluginKeyProcessor) (void *cls,
163 unsigned int count); 180 const struct GNUNET_HashCode *key,
181 unsigned int count);
164 182
165 183
166/** 184/**
@@ -170,8 +188,9 @@ typedef void (*PluginKeyProcessor) (void *cls,
170 * @param proc function to call on each key 188 * @param proc function to call on each key
171 * @param proc_cls closure for @a proc 189 * @param proc_cls closure for @a proc
172 */ 190 */
173typedef void (*PluginGetKeys) (void *cls, 191typedef void
174 PluginKeyProcessor proc, void *proc_cls); 192(*PluginGetKeys) (void *cls,
193 PluginKeyProcessor proc, void *proc_cls);
175 194
176 195
177/** 196/**
@@ -192,11 +211,14 @@ typedef void (*PluginGetKeys) (void *cls,
192 * proc should be called with NULL if there is no result 211 * proc should be called with NULL if there is no result
193 * @param proc_cls closure for @a proc 212 * @param proc_cls closure for @a proc
194 */ 213 */
195typedef void (*PluginGetKey) (void *cls, uint64_t offset, 214typedef void
196 const struct GNUNET_HashCode * key, 215(*PluginGetKey) (void *cls,
197 const struct GNUNET_HashCode * vhash, 216 uint64_t offset,
198 enum GNUNET_BLOCK_Type type, 217 const struct GNUNET_HashCode *key,
199 PluginDatumProcessor proc, void *proc_cls); 218 const struct GNUNET_HashCode *vhash,
219 enum GNUNET_BLOCK_Type type,
220 PluginDatumProcessor proc,
221 void *proc_cls);
200 222
201 223
202/** 224/**
@@ -209,18 +231,23 @@ typedef void (*PluginGetKey) (void *cls, uint64_t offset,
209 * @param proc function to call the value (once only). 231 * @param proc function to call the value (once only).
210 * @param proc_cls closure for @a proc 232 * @param proc_cls closure for @a proc
211 */ 233 */
212typedef void (*PluginGetRandom) (void *cls, PluginDatumProcessor proc, 234typedef void
213 void *proc_cls); 235(*PluginGetRandom) (void *cls,
236 PluginDatumProcessor proc,
237 void *proc_cls);
214 238
215 239
216/** 240/**
217 * Update continuation. 241 * Update continuation.
218 * 242 *
219 * @param cls closure 243 * @param cls closure
220 * @param status GNUNET_OK or GNUNET_SYSERROR 244 * @param status #GNUNET_OK or #GNUNET_SYSERROR
221 * @param msg error message on error 245 * @param msg error message on error
222 */ 246 */
223typedef void (*PluginUpdateCont) (void *cls, int status, char *msg); 247typedef void
248(*PluginUpdateCont) (void *cls,
249 int status,
250 const char *msg);
224 251
225 252
226/** 253/**
@@ -243,9 +270,13 @@ typedef void (*PluginUpdateCont) (void *cls, int status, char *msg);
243 * @param cont continuation called with success or failure status 270 * @param cont continuation called with success or failure status
244 * @param cons_cls continuation closure 271 * @param cons_cls continuation closure
245 */ 272 */
246typedef void (*PluginUpdate) (void *cls, uint64_t uid, int delta, 273typedef void
247 struct GNUNET_TIME_Absolute expire, 274(*PluginUpdate) (void *cls,
248 PluginUpdateCont cont, void *cont_cls); 275 uint64_t uid,
276 int delta,
277 struct GNUNET_TIME_Absolute expire,
278 PluginUpdateCont cont,
279 void *cont_cls);
249 280
250 281
251/** 282/**
@@ -260,9 +291,12 @@ typedef void (*PluginUpdate) (void *cls, uint64_t uid, int delta,
260 * @param proc function to call on the matching value 291 * @param proc function to call on the matching value
261 * @param proc_cls closure for @a proc 292 * @param proc_cls closure for @a proc
262 */ 293 */
263typedef void (*PluginGetType) (void *cls, uint64_t offset, 294typedef void
264 enum GNUNET_BLOCK_Type type, 295(*PluginGetType) (void *cls,
265 PluginDatumProcessor proc, void *proc_cls); 296 uint64_t offset,
297 enum GNUNET_BLOCK_Type type,
298 PluginDatumProcessor proc,
299 void *proc_cls);
266 300
267 301
268/** 302/**
@@ -270,8 +304,8 @@ typedef void (*PluginGetType) (void *cls, uint64_t offset,
270 * 304 *
271 * @param cls closure 305 * @param cls closure
272 */ 306 */
273typedef void (*PluginDrop) (void *cls); 307typedef void
274 308(*PluginDrop) (void *cls);
275 309
276 310
277/** 311/**