diff options
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r-- | src/include/gnunet_container_lib.h | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index e2a0787c8..1adae17b1 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Christian Grothoff (and other contributing authors) | 3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -201,11 +201,16 @@ typedef int (*GNUNET_CONTAINER_MetaDataProcessor) (void *cls, | |||
201 | 201 | ||
202 | /** | 202 | /** |
203 | * Create a fresh MetaData token. | 203 | * Create a fresh MetaData token. |
204 | * | ||
205 | * @return empty meta-data container | ||
204 | */ | 206 | */ |
205 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void); | 207 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void); |
206 | 208 | ||
207 | /** | 209 | /** |
208 | * Duplicate a MetaData token. | 210 | * Duplicate a MetaData token. |
211 | * | ||
212 | * @param meta what to duplicate | ||
213 | * @return duplicate meta-data container | ||
209 | */ | 214 | */ |
210 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const | 215 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const |
211 | struct | 216 | struct |
@@ -214,12 +219,18 @@ struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const | |||
214 | 219 | ||
215 | /** | 220 | /** |
216 | * Free meta data. | 221 | * Free meta data. |
222 | * | ||
223 | * @param md what to free | ||
217 | */ | 224 | */ |
218 | void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData | 225 | void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData |
219 | *md); | 226 | *md); |
220 | 227 | ||
221 | /** | 228 | /** |
222 | * Test if two MDs are equal. | 229 | * Test if two MDs are equal. |
230 | * | ||
231 | * @param md1 first value to check | ||
232 | * @param md2 other value to check | ||
233 | * @return GNUNET_YES if they are equal | ||
223 | */ | 234 | */ |
224 | int GNUNET_CONTAINER_meta_data_test_equal (const struct | 235 | int GNUNET_CONTAINER_meta_data_test_equal (const struct |
225 | GNUNET_CONTAINER_MetaData *md1, | 236 | GNUNET_CONTAINER_MetaData *md1, |
@@ -229,6 +240,10 @@ int GNUNET_CONTAINER_meta_data_test_equal (const struct | |||
229 | 240 | ||
230 | /** | 241 | /** |
231 | * Extend metadata. | 242 | * Extend metadata. |
243 | * | ||
244 | * @param md metadata to extend | ||
245 | * @param type type of the new entry | ||
246 | * @param data value for the entry | ||
232 | * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists | 247 | * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists |
233 | */ | 248 | */ |
234 | int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | 249 | int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, |
@@ -237,6 +252,10 @@ int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | |||
237 | 252 | ||
238 | /** | 253 | /** |
239 | * Remove an item. | 254 | * Remove an item. |
255 | * | ||
256 | * @param type type of the item to remove | ||
257 | * @param data specific value to remove, NULL to remove all | ||
258 | * entries of the given type | ||
240 | * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md | 259 | * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md |
241 | */ | 260 | */ |
242 | int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, | 261 | int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, |
@@ -246,6 +265,8 @@ int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, | |||
246 | /** | 265 | /** |
247 | * Add the current time as the publication date | 266 | * Add the current time as the publication date |
248 | * to the meta-data. | 267 | * to the meta-data. |
268 | * | ||
269 | * @param md metadata to modify | ||
249 | */ | 270 | */ |
250 | void GNUNET_CONTAINER_meta_data_add_publication_date (struct | 271 | void GNUNET_CONTAINER_meta_data_add_publication_date (struct |
251 | GNUNET_CONTAINER_MetaData | 272 | GNUNET_CONTAINER_MetaData |
@@ -254,6 +275,9 @@ void GNUNET_CONTAINER_meta_data_add_publication_date (struct | |||
254 | /** | 275 | /** |
255 | * Iterate over MD entries, excluding thumbnails. | 276 | * Iterate over MD entries, excluding thumbnails. |
256 | * | 277 | * |
278 | * @param md metadata to inspect | ||
279 | * @param iterator function to call on each entry | ||
280 | * @param closure closure for iterator | ||
257 | * @return number of entries | 281 | * @return number of entries |
258 | */ | 282 | */ |
259 | int GNUNET_CONTAINER_meta_data_get_contents (const struct | 283 | int GNUNET_CONTAINER_meta_data_get_contents (const struct |
@@ -263,6 +287,9 @@ int GNUNET_CONTAINER_meta_data_get_contents (const struct | |||
263 | 287 | ||
264 | /** | 288 | /** |
265 | * Get the first MD entry of the given type. | 289 | * Get the first MD entry of the given type. |
290 | * | ||
291 | * @param md metadata to inspect | ||
292 | * @param type type to look for | ||
266 | * @return NULL if we do not have any such entry, | 293 | * @return NULL if we do not have any such entry, |
267 | * otherwise client is responsible for freeing the value! | 294 | * otherwise client is responsible for freeing the value! |
268 | */ | 295 | */ |
@@ -272,7 +299,9 @@ char *GNUNET_CONTAINER_meta_data_get_by_type (const struct | |||
272 | 299 | ||
273 | /** | 300 | /** |
274 | * Get the first matching MD entry of the given types. | 301 | * Get the first matching MD entry of the given types. |
275 | * @paarm ... -1-terminated list of types | 302 | * |
303 | * @param md metadata to inspect | ||
304 | * @param ... -1-terminated list of types | ||
276 | * @return NULL if we do not have any such entry, | 305 | * @return NULL if we do not have any such entry, |
277 | * otherwise client is responsible for freeing the value! | 306 | * otherwise client is responsible for freeing the value! |
278 | */ | 307 | */ |
@@ -283,6 +312,7 @@ char *GNUNET_CONTAINER_meta_data_get_first_by_types (const struct | |||
283 | /** | 312 | /** |
284 | * Get a thumbnail from the meta-data (if present). | 313 | * Get a thumbnail from the meta-data (if present). |
285 | * | 314 | * |
315 | * @param md metadata to inspect | ||
286 | * @param thumb will be set to the thumbnail data. Must be | 316 | * @param thumb will be set to the thumbnail data. Must be |
287 | * freed by the caller! | 317 | * freed by the caller! |
288 | * @return number of bytes in thumbnail, 0 if not available | 318 | * @return number of bytes in thumbnail, 0 if not available |
@@ -294,6 +324,9 @@ size_t GNUNET_CONTAINER_meta_data_get_thumbnail (const struct | |||
294 | /** | 324 | /** |
295 | * Extract meta-data from a file. | 325 | * Extract meta-data from a file. |
296 | * | 326 | * |
327 | * @param md metadata to set | ||
328 | * @param filename name of file to inspect | ||
329 | * @param extractors plugins to use | ||
297 | * @return GNUNET_SYSERR on error, otherwise the number | 330 | * @return GNUNET_SYSERR on error, otherwise the number |
298 | * of meta-data items obtained | 331 | * of meta-data items obtained |
299 | */ | 332 | */ |
@@ -315,12 +348,13 @@ enum GNUNET_CONTAINER_MetaDataSerializationOptions | |||
315 | /** | 348 | /** |
316 | * Serialize meta-data to target. | 349 | * Serialize meta-data to target. |
317 | * | 350 | * |
351 | * @param md metadata to serialize | ||
318 | * @param size maximum number of bytes available | 352 | * @param size maximum number of bytes available |
319 | * @param opt is it ok to just write SOME of the | 353 | * @param opt is it ok to just write SOME of the |
320 | * meta-data to match the size constraint, | 354 | * meta-data to match the size constraint, |
321 | * possibly discarding some data? | 355 | * possibly discarding some data? |
322 | * @return number of bytes written on success, | 356 | * @return number of bytes written on success, |
323 | * GNUNET_SYSERR on error (typically: not enough | 357 | * -1 on error (typically: not enough |
324 | * space) | 358 | * space) |
325 | */ | 359 | */ |
326 | ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct | 360 | ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct |
@@ -334,9 +368,12 @@ ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct | |||
334 | /** | 368 | /** |
335 | * Compute size of the meta-data in | 369 | * Compute size of the meta-data in |
336 | * serialized form. | 370 | * serialized form. |
371 | * | ||
372 | * @param md metadata to inspect | ||
337 | * @param opt is it ok to just write SOME of the | 373 | * @param opt is it ok to just write SOME of the |
338 | * meta-data to match the size constraint, | 374 | * meta-data to match the size constraint, |
339 | * possibly discarding some data? | 375 | * possibly discarding some data? |
376 | * @return number of bytes needed for serialization, -1 on error | ||
340 | */ | 377 | */ |
341 | ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct | 378 | ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct |
342 | GNUNET_CONTAINER_MetaData | 379 | GNUNET_CONTAINER_MetaData |
@@ -347,6 +384,8 @@ ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct | |||
347 | 384 | ||
348 | /** | 385 | /** |
349 | * Deserialize meta-data. Initializes md. | 386 | * Deserialize meta-data. Initializes md. |
387 | * | ||
388 | * @param input serialized meta-data. | ||
350 | * @param size number of bytes available | 389 | * @param size number of bytes available |
351 | * @return MD on success, NULL on error (i.e. | 390 | * @return MD on success, NULL on error (i.e. |
352 | * bad format) | 391 | * bad format) |
@@ -359,6 +398,7 @@ struct GNUNET_CONTAINER_MetaData | |||
359 | * Does the meta-data claim that this is a directory? | 398 | * Does the meta-data claim that this is a directory? |
360 | * Checks if the mime-type is that of a GNUnet directory. | 399 | * Checks if the mime-type is that of a GNUnet directory. |
361 | * | 400 | * |
401 | * @param md metadata to inspect | ||
362 | * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if | 402 | * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if |
363 | * we have no mime-type information (treat as 'GNUNET_NO') | 403 | * we have no mime-type information (treat as 'GNUNET_NO') |
364 | */ | 404 | */ |