convert fs publish to MQ
[oweals/gnunet.git] / src / include / gnunet_container_lib.h
index cfa494578fba0636fd85a1dc28d577e85fe2e39e..03c47c2019b701d24858411c7ce4748759e8e7b0 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001-2015 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001-2015 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 */
 
 /**
- * @file include/gnunet_container_lib.h
- * @brief container classes for GNUnet
  * @author Christian Grothoff
  * @author Nils Durner
- * @defgroup hashmap multi hash-map
- * @defgroup heap min- or max-heap with arbitrary element removal
- * @defgroup bloomfilter Bloom filter (probabilistic set tests)
- * @defgroup dll Doubly-linked list
- * @defgroup metadata Meta data (GNU libextractor key-value pairs)
+ *
+ * @file
+ * Container classes for GNUnet
+ *
+ * @defgroup hashmap  Container library: MultiHashMap
+ * Hash map with multiple values per key.
+ *
+ * @see [Documentation](https://gnunet.org/util_multihashmap)
+ *
+ * @defgroup heap  Container library: Heap
+ * Min- or max-heap with arbitrary element removal
+ *
+ * @defgroup bloomfilter  Container library: Bloom filter
+ * Probabilistic set tests
+ *
+ * @defgroup dll  Container library: Doubly-linked list
+ *
+ * @see [Documentation](https://gnunet.org/mdll-api)
+ *
+ * @defgroup metadata  Container library: Metadata
+ * GNU libextractor key-value pairs
  */
 
 #ifndef GNUNET_CONTAINER_LIB_H
 /* add error and config prototypes */
 #include "gnunet_crypto_lib.h"
 
-#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
 
-#include <extractor.h>
+/**
+ * Try to compress the given block of data using libz.  Only returns
+ * the compressed block if compression worked and the new block is
+ * actually smaller.  Decompress using #GNUNET_decompress().
+ *
+ * @param data block to compress; if compression
+ *        resulted in a smaller block, the first
+ *        bytes of data are updated to the compressed
+ *        data
+ * @param old_size number of bytes in data
+ * @param[out] result set to the compressed data, if compression worked
+ * @param[out] new_size set to size of result, if compression worked
+ * @return #GNUNET_YES if compression reduce the size,
+ *         #GNUNET_NO if compression did not help
+ */
+int
+GNUNET_try_compression (const char *data,
+                        size_t old_size,
+                        char **result,
+                        size_t *new_size);
 
 
+/**
+ * Decompress input, return the decompressed data as output.  Dual to
+ * #GNUNET_try_compression(). Caller must set @a output_size to the
+ * number of bytes that were originally compressed.
+ *
+ * @param input compressed data
+ * @param input_size number of bytes in input
+ * @param output_size expected size of the output
+ * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
+ */
+char *
+GNUNET_decompress (const char *input,
+                   size_t input_size,
+                   size_t output_size);
+
+
+#if HAVE_EXTRACTOR_H
+
+#include <extractor.h>
 
 #else
 
@@ -986,7 +1037,12 @@ typedef int
                                      void *value);
 
 
+/**
+ * Hash map from peer identities to values.
+ */
 struct GNUNET_CONTAINER_MultiPeerMap;
+
+
 /**
  * @ingroup hashmap
  * Create a multi peer map (hash map for public keys of peers).